安卓:如何在BiometricPrompt上只指定人脸识别对话框? |
您所在的位置:网站首页 › biometricprompt › 安卓:如何在BiometricPrompt上只指定人脸识别对话框? |
我需要通过touchid和faceid实现生物识别登录,这允许用户选择他/她想要启用的触摸屏或人脸识别。 我使用了最新的android库(androidx.biometric:biometric)来实现这一点,但在promt上分离触摸和面部时遇到了麻烦。 下图显示了我的问题。 ![]() 下面是我的代码: 代码语言:javascript复制private fun displayBiometricPrompt( activity: FragmentActivity, biometricCallback: BiometricCallback ) { context.let { val biometricPrompt = BiometricPrompt( activity, it?.mainExecutor!!, object : BiometricPrompt.AuthenticationCallback() { override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { super.onAuthenticationSucceeded(result) biometricCallback.onAuthenticationSuccessful() } override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { super.onAuthenticationError(errorCode, errString) biometricCallback.onAuthenticationError(errorCode, errString) } override fun onAuthenticationFailed() { super.onAuthenticationFailed() biometricCallback.onAuthenticationFailed() } } ) biometricPrompt.authenticate( BiometricPrompt.PromptInfo.Builder() .setTitle(title) .setSubtitle(subtitle) .setDescription(description) .setConfirmationRequired(false) .setNegativeButtonText(negativeButtonText) .build() ) } } |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |