I am using androidX biometric prompt in my application. In that I am having three queries,
Asked
Active
Viewed 1,480 times
0
-
for your question one please have a look at this [answer](https://stackoverflow.com/a/43975716/7948109), Q2 is not clear, Q3 you customization in default prompt is not available. – Rahul Gaur Feb 10 '20 at 06:56
-
@RahulGaur for q1, androidX biometric prompt doesn't have the cancellation signal option (link which you've referred, using cancellation signal). q2. In default biometric prompt, we have an option to use password ( if device credential enabled ). If we click on that option, the above screen will appear right?. Is there any option to display the password screen, without user clicking use password.. – Naveen Kumar Feb 10 '20 at 09:05
1 Answers
2
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()

Lena Bru
- 13,521
- 11
- 61
- 126
-
for the 2nd answer, if user clicks on use password option in prompt, then only the password screen will appear right ?? (if device credential enabled ). Is there any option to display the password screen, without displaying the prompt..? – Naveen Kumar Feb 10 '20 at 09:15
-
I don't think so, it would be too invasive, would you like an app that locks your device ? – Lena Bru Feb 10 '20 at 14:54