Complete the code to create a BiometricPrompt instance.
val biometricPrompt = BiometricPrompt(this, ContextCompat.getMainExecutor(this), [1])The BiometricPrompt constructor requires an AuthenticationCallback to handle authentication events.
Complete the code to build the BiometricPrompt.PromptInfo.
val promptInfo = BiometricPrompt.PromptInfo.Builder() .setTitle("Login") .setSubtitle("Use your fingerprint") .setNegativeButtonText([1]) .build()
The negative button text should be a clear cancel action, usually labeled "Cancel".
Fix the error in the authentication callback method name.
val authenticationCallback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthentication[1](result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
// Handle success
}
}The correct method name is onAuthenticationSucceeded with 'Succeeded' at the end.
Fill both blanks to check if biometric authentication is available and strong.
val biometricManager = BiometricManager.from(this) if (biometricManager.canAuthenticate([1]) == [2]) { // Biometric authentication is available }
Use BIOMETRIC_STRONG to specify strong biometrics and check for BIOMETRIC_SUCCESS to confirm availability.
Fill all three blanks to start biometric authentication with the prompt info.
biometricPrompt.[1]( [2], [3] )
Call authenticate with the prompt info and a new cancellation signal to start authentication.