0

我在我的 Android 应用程序中添加了生物识别提示。所以在应用程序启动时,我能够显示提示,如果成功能够在仪表板屏幕上重定向用户。如果用户失败,我想显示系统密码作为验证的辅助选项。如何使用生物识别提示来做到这一点?

mBiometricManager = new BiometricManager.BiometricBuilder(FingerprintActivity.this)
                .setTitle(getString(R.string.biometric_title))
                .setSubtitle(getString(R.string.biometric_subtitle))
                .setDescription(getString(R.string.biometric_description))        
                .setNegativeButtonText(getString(R.string.biometric_negative_button_text))
                .build();

 mBiometricManager.authenticate(FingerprintActivity.this);
4

2 回答 2

0

您可以通过扩展来处理BiometricPrompt.AuthenticationCallback,有两种主要的处理失败状态的方法。onAuthenticationErroronAuthenticationFailed

onAuthenticationFailed

当指纹与设备上注册的任何指纹都不匹配时,将触发此回调。

onAuthenticationError

当遇到不可恢复的错误并且认证过程没有成功完成时,将触发此回调。回调提供了错误代码以识别错误原因

您可以使用设备管理 API在 Biometic auth 失败的情况下显示系统密码。

于 2019-06-24T07:25:14.237 回答
0

在你的生物识别提示上添加这个

.setDeviceCredentialAllowed(true)

但检查手机是否有密码/密码设置:

android.app.KeyguardManager#isDeviceSecure()
于 2020-06-17T12:45:18.567 回答