I am using FingerprintManager
to authenticate my app with fingerprint.
I have and android View
with the fingerprint ui and when the FingerprintManager.authenticate
callbacks are called I handle the callbacks in the view, e.g change fingerprint icon, error text etc.
Now in Android P, I have to use BiometricPrompt
, which is easy enough to use, but forces me to have an Activity
in order to work properly
Is there a way to make BiometricPrompt
work in a plain android view?
this is my working code to launch the prompt in an activity
Signature signature = createSignature();
biometricPrompt = new BiometricPrompt.Builder(context)
.setDescription("Description")
.setTitle("Title")
.setSubtitle("Subtitle")
.setNegativeButton("Cancel", context.getMainExecutor(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Log.i(TAG, "Cancel button clicked");
}
})
.build();
biometricPrompt.authenticate(new BiometricPrompt.CryptoObject(signature), cancellationSignal, context.getMainExecutor() , new BiometricPrompt.AuthenticationCallback() {...}
where context is an activity that without it it can not work