首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我使用生物识别api,但在android 10中只显示手指身份验证而不显示面部身份验证

我使用生物识别api,但在android 10中只显示手指身份验证而不显示面部身份验证
EN

Stack Overflow用户
提问于 2021-10-07 07:01:10
回答 2查看 346关注 0票数 0

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

代码语言:javascript
复制
 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)
        }
    }

但它只显示手指身份验证

我已经在可以解锁屏幕的设置中打开了人脸认证

我怎么才能解决它呢?

EN

回答 2

Stack Overflow用户

发布于 2021-10-07 08:24:12

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

票数 0
EN

Stack Overflow用户

发布于 2021-10-10 08:46:49

并不是所有使用FaceID的设备都通过system/compat BiometricPrompt API提供面部身份验证。FaceUnlock在像素和三星设备上运行良好,但不适用于许多原始设备制造商解决方案(华为、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

上述项目还允许通过非官方应用程序接口在小米、华为、摩托罗拉和其他设备上使用FaceID。对于您的情况,使用Vivo FaceID,库有相关的实现,但没有任何保证。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69476731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档