I face an issue on Android 11 (API 30). The BiometricPrompt.AuthenticationCallback() is not triggered.
Step to reproduce:
- Show Biometric prompt
- Press the back key to make the dialog be dismissed and onAuthenticationError triggered.
- try to show the Biometric again.
- Press the back key again or provide the correct/wrong biometric. There is no authentication callback triggered.
val callback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errCode: Int, errString: CharSequence) {
super.onAuthenticationError(errCode, errString)
if (errCode == BiometricPrompt.ERROR_USER_CANCELED)
// user click outside or back key -> try to show biometric prompt again
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
processFailed()
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
}
}
biometricPrompt = BiometricPrompt(activity, executor, callback)
biometricPrompt.authenticate(promptInfo)
Expected: at least one of the AuthenticationCallback functions should be triggered. Does anyone have experience with it before (why the callbacks don't trigger on the 2nd biometric prompt? or is there any way to avoid the biometric prompt close in this scenario?
Note
- I use androidx.biometric:biometric version 1.2.0-alpha01, I tried to update to the latest version, and the same issue still appears.
- Only happens on Android 11.
Thank you in advance!