我在我的应用程序中使用 androidX 生物识别提示。因为我有三个疑问,
问问题
771 次
1 回答
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 }
我不确定,但我认为如果您显示提示,并且启用凭据为 true,则用户在提示“使用密码”上有一个按钮
* 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()
于 2020-02-10T07:12:19.977 回答