I'm using BiometricPrompt from androidx.biometric:biometric:1.0.0-beta02
for the authenticate process.
But i face very strange problem.
First time i call biometricsPromt.authenticate()
everything works fine, the library shows me the screen depending what security method is set(pattern,fingerprint, password and etc…) then the callback is called and everything is good.
The problem is when i call biometricsPromt.authenticate()
for the second time i got the error:
E/DeviceCredentialHandler: onCreate: Executor and/or callback was null!
I'm passing executor and callback of course -> they are not null
Does anyone face the same problem or have some idea what can be the problem?
This is how i'm creating the BiometricPromt
`
companion object {
private val executor: Executor by lazy {
Executors.newSingleThreadExecutor()
}
fun showBiometricsPrompt(
activity: FragmentActivity,
callback: BiometricPrompt.AuthenticationCallback
): BiometricPrompt {
val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle(activity.getString(R.string.title_authentication))
.setDescription(activity.getString(R.string.msg_authenticate_first))
.setDeviceCredentialAllowed(true)
.build()
val biometricPrompt =
BiometricPrompt(
activity,
executor, callback
)
biometricPrompt.authenticate(promptInfo)
return biometricPrompt
}
`
And here is how i called:
`
BiometricsHelper.showBiometricsPrompt(
this,
object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
showToastMsg(errString.toString())
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
}
})
`