Add Biometric Authentication to any Android app
This application uses android Biometric Prompt Library to authenticate user using fingerprint.
Gradle Dependecydependencies {
implementation 'androidx.biometric:biometric:1.0.0-alpha03'
}
new BiometricPrompt.PromptInfo.Builder()
.setTitle("Login")
.setSubtitle("Login to your account!")
.setDescription("Place your finger on the device home button to verify your identity")
.setNegativeButtonText("CANCEL")
.build();
The BiometricPrompt
class has the following callback methods:
new BiometricPrompt(activity, executor, new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
// ................
}
@Override
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
// .............
}
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
// ................
}
});