我正在编写一个应用程序功能,以使用Biometric指纹认证API 来认证用户。它与BiometricPrompt API的组合可以按预期工作。
通常,它会显示自己的UI对话框,因此可以在Android设备上进行统一。(来自Fingerprint Manager API的改进)
在一种设备测试方案中,我遇到了显示屏内(在屏幕上,例如Oneplus 6T设备)指纹支持而不是后部生物识别硬件选项的问题。
当我在其上运行应用程序时,在调用biometricPrompt.authenticate(..)而不是对话框时会显示显示指纹认证选项。可以,并由BiometricPrompt的内部API管理。
但是,这会给开发人员带来一些管理上的矛盾。
现在的问题是
编辑:我正在使用的代码参考:
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)