【问题标题】:I use Biometric api but only show finger Authentication no Face Authentication in android 10我使用生物识别 api,但在 android 10 中只显示手指身份验证没有人脸身份验证
【发布时间】:2021-10-10 17:39:54
【问题描述】:

我在android 10上使用vivo,我的代码非常简单,只需一个按钮并单击它进行身份验证

 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_face_id)

        biometricPrompt = BiometricPrompt(this, ContextCompat.getMainExecutor(this), object : BiometricPrompt.AuthenticationCallback() {

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

               Log.d("Huang", " error $errString")
            }

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

                Log.d("Huang", " success")
            }

            override fun onAuthenticationFailed() {
                super.onAuthenticationFailed()

                Log.d("Huang", " fail")
            }
        })

        promptInfo  = BiometricPrompt.PromptInfo.Builder()
            .setTitle("Biometric login for my app")
            .setSubtitle("Log in using your biometric credential")
            .setNegativeButtonText("Use account password")
            .setDeviceCredentialAllowed(true)
            .build()

        val button = findViewById<Button>(R.id.login)
        button.setOnClickListener {

            biometricPrompt.authenticate(promptInfo)
        }
    }

但它只显示手指身份验证 我已经在可以解锁屏幕的设置中打开人脸验证 我该如何解决它

【问题讨论】:

  • 简单的回答是,您的手机不符合 Google Biometrics API,因此不支持人脸验证。
  • @Javatar Okay:(。你知道什么设备支持吗?我知道 Pixels 支持它,还有什么?
  • 不,市场上的设备太多了,而且一直在变化。

标签: android android-biometric-prompt android-biometric


【解决方案1】:

实际上,用于面部解锁的传感器(通常是摄像头)可能不会用于生物特征认证。因为生物特征认证需要安全的硬件,例如人脸 ID 或指纹。但是,您仍然可以尝试使用.setAllowedAuthenticators(BIOMETRIC_WEAK) 降低安全级别,如this documentation 中所述。

【讨论】:

  • 感谢您的回答。我添加了.setAllowedAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG),但没有任何改变。
  • 所以,我认为您的手机可能不支持人脸生物特征认证。
  • 好的:(。你知道什么设备支持吗?我知道Pixels支持它,还有什么?
  • 我不确定。我是 Pixel 4xl 用户,是的,这款手机支持人脸 ID。但根据这篇文章的评论,三星 S10+ 也可能支持面部识别。 stackoverflow.com/a/63343041/6183507
  • 顺便说一句,我意识到我在 BIOMETRIC_STRONG 上的输入错误,因此我更新了帖子。请尝试使用 BIOMETRIC_WEAK。
【解决方案2】:

并非所有配备 FaceID 的设备都通过 system/compat BiometricPrompt API 提供人脸身份验证。 FaceUnlock 在 Pixel 和三星设备上运行良好,但不适用于许多 OEM 解决方案(华为、Oppo、小米等)。

这里描述了为什么会发生这种情况:https://github.com/Salat-Cx65/AdvancedBiometricPromptCompat#i-have-a-device-that-can-be-unlocked-using-fingerprintfaceiris-andor-i-can-use-this-biometric-type-in-pre-installed-apps-but-it-doesnt-work-on-3rd-party-apps-can--you-help

上述项目还允许通过非官方 API 在小米、华为、Moto 和其他设备上使用 FaceID。对于您的情况,使用 Vivo FaceID,该库有相关的实现,但没有任何保证。

【讨论】:

    猜你喜欢
    • 2018-11-16
    • 1970-01-01
    • 2020-04-30
    • 2015-05-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-12
    • 2020-01-31
    • 2011-04-13
    相关资源
    最近更新 更多