我在我的应用程序中使用了androidX生物识别提示。因为我有三个查询,
答案 0 :(得分:2)
5次尝试失败后,提示自动关闭。 不过,您可以覆盖BiometricCallback并覆盖“ onAuthenticationFailed”以计算失败次数
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
}
我不确定,但是我认为如果您显示提示且启用了凭据,则用户在提示上会有一个按钮“使用密码”
* 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()