1

So I have app lock on my app that uses the devices lock method - I use Biometrics 1.0.1 which support all android versions, however on KitKat when I press unlock, it shows tihs toast:

authentication error: This device does not have a fingerprint sensor.

Even though I use .setDeviceCredentialAllowed(true) which should use devices PIN or pattern if no fingerprint is available.

keyguardManager.isKeyguardSecure returns true

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

        // Prompt appears when user clicks "Unlock".
        val biometricLoginButton = unlock_button
        biometricLoginButton.setOnClickListener {
            biometricPrompt.authenticate(promptInfo)
        }
4

1 回答 1

1

setDeviceCredentialAllowed()方法仅支持 Api 21+

因为这个 api 在内部使用了KeyguardManager.createConfirmDeviceCredentialIntent(CharSequence, CharSequence) 这个方法在ReferenceAPI 21上添加和弃用API 29

来自Api 文档

在 P 及以下版本中,一旦显示设备凭据提示,BiometricPrompt.cancelAuthentication() 将不起作用,因为库内部启动 KeyguardManager.createConfirmDeviceCredentialIntent(CharSequence, CharSequence),它没有用于取消的公共 API。

于 2019-12-19T17:47:42.743 回答