在装有Android Q的三星银河M01设备中未检测到生物识别信息?

问题描述

以下是我用于检测生物特征功能的代码

class MainActivity : AppCompatActivity() {

    private var executor: Executor? = null
    private var biometricPrompt: BiometricPrompt? = null
    private var promptInfo: BiometricPrompt.PromptInfo? = null

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

        val bioMetricManager = BiometricManager.from(this)

        when (bioMetricManager.canAuthenticate()) {
            BiometricManager.BIOMETRIC_SUCCESS -> {
                executor = ContextCompat.getMainExecutor(this)

                promptInfo = BiometricPrompt.PromptInfo.Builder().setTitle("Biometric login for leaao")
                    .setSubtitle("Log in using biometric credentials").setDeviceCredentialAllowed(true).build()

                biometricPrompt = BiometricPrompt(this,executor!!,object : BiometricPrompt.AuthenticationCallback() {
                        override fun onAuthenticationError(errorCode: Int,errString: CharSequence) {
                            super.onAuthenticationError(errorCode,errString)
                            Log.i("here4","Authentication error: $errString")
                        }

                        override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
                            super.onAuthenticationSucceeded(result)
                            Log.i("here5","Success")
                        }

                        override fun onAuthenticationFailed() {
                            super.onAuthenticationFailed()
                            Log.i("here6","Authentication failed: ")
                        }
                    })

                biometricPrompt?.authenticate(promptInfo!!)
            }
            BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> {
                Log.i("here","No biometric features available on this device.")
            }
            BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> {
                Log.i("here2","Biometric features are currently unavailable.")
            }
            BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> {
                Log.i("here3","The user hasn't associated any biometric credentials with their account.")
            }
        }
    }
}

我已将<uses-permission android:name="android.permission.USE_BIOMETRIC" />添加到清单文件,并将implementation 'androidx.biometric:biometric:1.0.1'添加到gradle

仍然,我的代码无法检测到生物识别提示。我已经在手机上启用了人脸识别功能,但是当我打开应用程序时该功能不起作用。在我的代码中以BIOMETRIC_ERROR_HW_UNAVAILABLE为例。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...