Basic android example where you can find how to implement Biometrics Prompt
- Android API 21 - 31
- Gradle 7.2
- Kotlin 1.6.10
There are multiple options to display biometrics prompt. In this example there are 4 options:
Unlock with Biometric String
: Fingerprint authentication prompt will appear
Unlock with Biometric Weak
: Fingerprint and Face authentication prompt will appear
Unlock with Biometric Weak and Device Credential
: Fingerprint, Face and Device credential authentication prompt will appear
- Prompt's description can be modified
setDescription("New Description")
- In this case it has not been modified, so in the screenshots you can see that the description is in another language. The description is set to the default value and is set to the language of the device.
BiometricPrompt.PromptInfo.Builder().apply {
setTitle(activity.getString(R.string.prompt_info_title))
setDescription("New Description")
setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_WEAK or BiometricManager.Authenticators.DEVICE_CREDENTIAL)
setConfirmationRequired(false)
}.build()
-
Same in option
Unlock with Biometric Weak and Device Credential
, the device credential authentication button is set based on the device settings (pattern or PIN code) and also set based on the device language. -
This example has been done with Biometric Library
'androidx.biometric:biometric-ktx:1.2.0-alpha04'
-
To know more about biometrics check this link