List of usage examples for android.hardware.fingerprint FingerprintManager authenticate
public void authenticate(@NonNull CancellationSignal cancel, @NonNull Bundle bundle, @NonNull @CallbackExecutor Executor executor, @NonNull IBiometricPromptReceiver receiver, @NonNull BiometricAuthenticator.AuthenticationCallback callback)
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
private void startFingerprint() { TextView fingerprintTextView = (TextView) findViewById(R.id.scanfingerprinttext); FingerprintManager fingerprintManager = (FingerprintManager) MainApp.getAppContext() .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return;/*w w w . ja v a 2 s.co m*/ } KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (!keyguardManager.isKeyguardSecure()) { return; } else { generateKey(); if (cipherInit()) { cryptoObject = new FingerprintManager.CryptoObject(cipher); FingerprintHandler.Callback callback = new FingerprintHandler.Callback() { @Override public void onAuthenticated() { fingerprintResult(true); } @Override public void onFailed(String error) { Toast.makeText(MainApp.getAppContext(), error, Toast.LENGTH_LONG).show(); ImageView imageView = (ImageView) findViewById(R.id.fingerprinticon); int[][] states = new int[][] { new int[] { android.R.attr.state_activated }, new int[] { -android.R.attr.state_activated } }; int[] colors = new int[] { Color.parseColor("#FF0000"), Color.RED }; ColorStateList csl = new ColorStateList(states, colors); Drawable drawable = DrawableCompat.wrap(imageView.getDrawable()); DrawableCompat.setTintList(drawable, csl); imageView.setImageDrawable(drawable); } }; helper = new FingerprintHandler(fingerprintTextView, callback); cancellationSignal = new CancellationSignal(); if (ActivityCompat.checkSelfPermission(MainApp.getAppContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, helper, null); } } }