0
0
Android Kotlinmobile~10 mins

Biometric authentication in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a BiometricPrompt instance.

Android Kotlin
val biometricPrompt = BiometricPrompt(this, ContextCompat.getMainExecutor(this), [1])
Drag options to blanks, or click blank then click option'
AauthenticationCallback
BpromptInfo
Cexecutor
DbiometricManager
Attempts:
3 left
💡 Hint
Common Mistakes
Using the executor or promptInfo instead of the callback.
Passing biometricManager which is unrelated here.
2fill in blank
medium

Complete the code to build the BiometricPrompt.PromptInfo.

Android Kotlin
val promptInfo = BiometricPrompt.PromptInfo.Builder()
  .setTitle("Login")
  .setSubtitle("Use your fingerprint")
  .setNegativeButtonText([1])
  .build()
Drag options to blanks, or click blank then click option'
A"Retry"
B"Cancel"
C"OK"
D"Confirm"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OK' or 'Confirm' which confuse the cancel action.
Leaving the negative button text empty.
3fill in blank
hard

Fix the error in the authentication callback method name.

Android Kotlin
val authenticationCallback = object : BiometricPrompt.AuthenticationCallback() {
  override fun onAuthentication[1](result: BiometricPrompt.AuthenticationResult) {
    super.onAuthenticationSucceeded(result)
    // Handle success
  }
}
Drag options to blanks, or click blank then click option'
ASuccessed
BSuccess
CSucceededed
DSucceeded
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the method name causes it not to override properly.
Using 'Success' instead of 'Succeeded'.
4fill in blank
hard

Fill both blanks to check if biometric authentication is available and strong.

Android Kotlin
val biometricManager = BiometricManager.from(this)
if (biometricManager.canAuthenticate([1]) == [2]) {
  // Biometric authentication is available
}
Drag options to blanks, or click blank then click option'
ABiometricManager.Authenticators.BIOMETRIC_STRONG
BBiometricManager.Authenticators.DEVICE_CREDENTIAL
CBiometricManager.BIOMETRIC_SUCCESS
DBiometricManager.BIOMETRIC_ERROR_NO_HARDWARE
Attempts:
3 left
💡 Hint
Common Mistakes
Using DEVICE_CREDENTIAL instead of BIOMETRIC_STRONG.
Checking for BIOMETRIC_ERROR_NO_HARDWARE instead of BIOMETRIC_SUCCESS.
5fill in blank
hard

Fill all three blanks to start biometric authentication with the prompt info.

Android Kotlin
biometricPrompt.[1](
  [2],
  [3]
)
Drag options to blanks, or click blank then click option'
Aauthenticate
BpromptInfo
CCancellationSignal()
Dcancel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cancel' instead of 'authenticate'.
Passing wrong arguments or missing cancellation signal.