Reputation: 161
I am using androidX biometric prompt in my application. In that I am having three queries,
Is there any option to close the prompt, after counting three failure attempts.
Is there any option to display the password screen, without clicking use password button (if device credential enabled is true).
Is there any option to customize the prompt box.
Upvotes: 0
Views: 1943
Reputation: 13947
The prompt auto closes after 5 failed attempts. Nevertheless, you can override the BiometricCallback and override "onAuthenticationFailed" to count the number of fails
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
//You can count the number of failed attempts, and call the cancellation signal here, onAuthenticationError will not be called if you do
}
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
//explains to you in the errString why the authentication failed after *five* attempts
}
I'm not sure, but I think that if you display the prompt, with credential enabled true, the user has a button on the prompt "use password"
* The user will first be prompted to authenticate with biometrics, but also given the
* option to authenticate with their device PIN, pattern, or password. Developers should
* first check {@link KeyguardManager#isDeviceSecure()} before enabling this. If the device
* is not secure, {@link BiometricPrompt#BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL} will be
* returned in {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}}.
* Defaults to false.
*
* Note that {@link #setNegativeButton(CharSequence, Executor,
* DialogInterface.OnClickListener)} should not be set if this is set to true.
*
* @param allowed When true, the prompt will fall back to ask for the user's device
* credentials (PIN, pattern, or password).
* @return
*/
@NonNull public Builder setDeviceCredentialAllowed(boolean allowed) {
mBundle.putBoolean(KEY_ALLOW_DEVICE_CREDENTIAL, allowed);
return this;
}
3. only the text on it
val prompt =
BiometricPrompt.Builder(context).setTitle(title).setSubtitle(subtitleText).setDescription(description)
.setNegativeButton(negativeButton, executor!!, cancelListener).build()
Upvotes: 2