有人在自己的android应用程序中使用过android默认的FaceID身份验证功能吗?我在这里查阅了文件。
我正在Redmi 9中测试此功能,即Android Q(10(。Redmi 9具有人脸验证功能。当我调用hasSystemFeature()
时,我得到false
。由于这个faceID弹出窗口无法打开。
PackageManager pm = reactContext.getPackageManager();
pm.hasSystemFeature(PackageManager.FEATURE_FACE)
任何小费都会有帮助。谢谢
val biometricManager = BiometricManager.from(this)
when (biometricManager.canAuthenticate()) {
BiometricManager.BIOMETRIC_SUCCESS ->
Log.d("MY_APP_TAG", "App can authenticate using biometrics.")
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE ->
Log.e("MY_APP_TAG", "No biometric features available on this device.")
BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE ->
Log.e("MY_APP_TAG", "Biometric features are currently unavailable.")
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED ->
Log.e("MY_APP_TAG", "The user hasn't associated " +
"any biometric credentials with their account.")
}
请查看上的示例https://developer.android.com/training/sign-in/biometric-auth#kotlin如果有可用的生物识别硬件并由用户设置,则不使用软件包管理器来确定。
之后,使用教程中的下一个代码片段显示对话框:
...
promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric login for my app")
.setSubtitle("Log in using your biometric credential")
.setNegativeButtonText("Use account password")
.build()
...