I have implemented finger-print Biometric auth in my project. I have set a fallback auth in case user wants to use pattern/pin/passcode by clicking on "Use Password" button. I have done this by using setDeviceCredentialAllowed(true) which works for the first time. But whenever I do this again, the pattern/pin/passcode screen never appears again. I get a following log in the logcat console:
BiometricPromptCompat: Failed to check device credential. Parent handler not found
Here is my code for reference. Thanks in advance.
executor = ContextCompat.getMainExecutor(this);
biometricPrompt = new BiometricPrompt(MainActivity.this,
executor, new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode,
@NonNull CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
Toast.makeText(getApplicationContext(),
"Authentication error: " + errString, Toast.LENGTH_SHORT)
.show();
}
@Override
public void onAuthenticationSucceeded(
@NonNull BiometricPrompt.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
Toast.makeText(getApplicationContext(),
"Authentication succeeded!", Toast.LENGTH_SHORT).show();
}
@Override
public void onAuthenticationFailed() {
super.onAuthenticationFailed();
Toast.makeText(getApplicationContext(), "Authentication failed",
Toast.LENGTH_SHORT)
.show();
}
});
promptInfo = new BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric login for my app")
.setSubtitle("Log in using your biometric credential")
.setDeviceCredentialAllowed(true)
.setConfirmationRequired(true)
.build();
biometricPrompt.authenticate(promptInfo);