Я реализовал биометрическую аутентификацию, но она отлично работает на моем устройстве Samsung (Android 10), но не работает на одном плюшевом и MI-устройстве.
В Mi (Android 10) и одном плюшевом (Android 10) устройстве отображается только запрос отпечатка пальца, но не отображается опция аутентификации по лицу.
Я установил свой идентификатор лица в настройках обоих устройств, но он не работает. работает только в устройстве Samsung.
Я использовал код ниже
executor = ContextCompat.getMainExecutor(this)
biometricPrompt = BiometricPrompt(this, executor,
object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int,
errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
Toast.makeText(applicationContext,
"Authentication error: $errString", Toast.LENGTH_SHORT)
.show()
}
override fun onAuthenticationSucceeded(
result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
Toast.makeText(applicationContext,
"Authentication succeeded!", Toast.LENGTH_SHORT)
.show()
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
Toast.makeText(applicationContext, "Authentication failed",
Toast.LENGTH_SHORT)
.show()
}
})
promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric login for my app")
.setSubtitle("Log in using your biometric credential")
.setConfirmationRequired(true).
setNegativeButtonText("login")
.build()
val biometricLoginButton =
findViewById<TextView>(R.id.tvClick)
biometricLoginButton.setOnClickListener {
biometricPrompt.authenticate(promptInfo)
}