0

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

 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)
        }
    }

但它只显示手指身份验证 在此处输入图像描述 我已经在设置中打开面部身份验证可以解锁屏幕 我该在此处输入图像描述 如何解决

4

2 回答 2

0

实际上,用于面部解锁的传感器(通常是相机)可能不会用于生物特征认证。因为生物特征认证需要安全的硬件,例如人脸 ID 或指纹。但是,您仍然可以尝试.setAllowedAuthenticators(BIOMETRIC_WEAK)按照本文档中的说明降低安全级别。

于 2021-10-07T08:24:12.220 回答
0

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

这里描述了为什么会发生这种情况:https ://github.com/Salat-Cx65/AdvancedBiometricPromptCompat#i-have-a-device-that-c​​an-be-unlocked-using-fingerprintfaceiris-andor-i-can-use-this -预安装的应用程序中的生物识别类型,但它不会在 3rd-party-apps-can--you-help 上工作

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

于 2021-10-10T08:46:48.560 回答