相关疑难解决方法(0)

如何确定设备是否具有显示屏生物特征指纹支持?

我正在编写一个应用程序功能,以使用Biometric指纹认证API 来认证用户。它与BiometricPrompt API的组合可以按预期工作。

通常,它会显示自己的UI对话框,因此可以在Android设备上进行统一。(来自Fingerprint Manager API的改进)

在一种设备测试方案中,我遇到了显示屏内(在屏幕上,例如Oneplus 6T设备)指纹支持而不是后部生物识别硬件选项的问题。

当我在其上运行应用程序时,在调用biometricPrompt.authenticate(..)而不是对话框时会显示显示指纹认证选项。可以,并由BiometricPrompt的内部API管理。

但是,这会给开发人员带来一些管理上的矛盾。

  1. 当提供内置身份验证对话框时,所有回退错误将显示在对话框本身中。
  2. 但是在显示身份验证的情况下,我没有找到一种方法来自行显示错误消息。而且我必须处理这种后备并以自定义方式显示。

现在的问题是

  1. 有没有一种方法可以通过显示中的验证视图组件来管理/显示消息。
  2. 如何识别设备是否支持设备内生物特征认证。

编辑:我正在使用的代码参考:

import android.content.Context
import androidx.biometric.BiometricPrompt
import androidx.fragment.app.FragmentActivity
import java.lang.Exception
import java.util.concurrent.Executors
import javax.crypto.Cipher

class BiometricAuthenticationManager(private val context: Context) :
        BiometricPrompt.AuthenticationCallback() {

    private var biometricPrompt: BiometricPrompt? = null

    override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
        super.onAuthenticationError(errorCode, errString)
        biometricPrompt?.cancelAuthentication()
    }

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

    }

    override fun onAuthenticationFailed() {
        super.onAuthenticationFailed()
    }

    fun init(cipher: Cipher, promptInfo: BiometricPrompt.PromptInfo) { …
Run Code Online (Sandbox Code Playgroud)

android android-fingerprint-api in-display-fingerprint

9
推荐指数
1
解决办法
353
查看次数