【问题标题】:Android: How to specify only Face recognition dialog on BiometricPrompt?Android:如何在 BiometricPrompt 上仅指定人脸识别对话框?
【发布时间】:2021-01-21 23:24:21
【问题描述】:

我需要通过 touchid 和 faceid 实现生物识别登录,这允许用户选择他/她想要启用哪一个,触摸或人脸识别。

我使用最新的 android 库 (androidx.biometric:biometric) 来实现这一点,但在 promt 上分离触摸和面部时遇到了麻烦。

下图显示了我的问题。

这是我的代码:

private fun displayBiometricPrompt(
    activity: FragmentActivity,
    biometricCallback: BiometricCallback
) {
    context.let {
        val biometricPrompt = BiometricPrompt(
            activity,
            it?.mainExecutor!!,
            object : BiometricPrompt.AuthenticationCallback() {

                override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
                    super.onAuthenticationSucceeded(result)
                    biometricCallback.onAuthenticationSuccessful()
                }

                override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
                    super.onAuthenticationError(errorCode, errString)
                    biometricCallback.onAuthenticationError(errorCode, errString)
                }

                override fun onAuthenticationFailed() {
                    super.onAuthenticationFailed()
                    biometricCallback.onAuthenticationFailed()
                }
            }
        )
        biometricPrompt.authenticate(
            BiometricPrompt.PromptInfo.Builder()
                .setTitle(title)
                .setSubtitle(subtitle)
                .setDescription(description)
                .setConfirmationRequired(false)
                .setNegativeButtonText(negativeButtonText)
                .build()
        )
    }
}

【问题讨论】:

    标签: android kotlin biometrics touch-id face-id


    【解决方案1】:

    无法指定类型。虹膜和面部扫描仪仅从 Android 10 开始支持。在此之前,仅支持指纹。

    如果设备有多个传感器,每个传感器都被定义为“弱”或“强”、“可靠”。 Biometric API 会选择最可靠的传感器并默认提供给用户。

    【讨论】:

    • 感谢您的回复胜利者,这实际上很有帮助,我们的团队可能需要考虑更改我们的 Android 特定流程
    • 谢谢你的回答,你能把参考链接放上去了解更多吗?
    猜你喜欢
    • 2012-07-26
    • 2018-09-15
    • 2011-12-11
    • 2012-12-21
    • 2013-12-22
    • 1970-01-01
    • 2015-10-13
    • 2019-05-19
    • 2011-12-14
    相关资源
    最近更新 更多