在 Pixel 4XL (Android Q) 上测试生物识别失败,返回BIOMETRIC_ERROR_HW_UNAVAILABLE
.
我已设置人脸识别
安卓清单文件
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
梯度依赖
dependencies {
implementation "androidx.biometric:biometric:1.0.1"
}
测试代码
private boolean setBIOSetup() {
BiometricManager biometricManager = BiometricManager.from(getActivity());
switch (biometricManager.canAuthenticate()) {
case BiometricManager.BIOMETRIC_SUCCESS:
return true;
case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
Toast.makeText(getActivity(), "No biometric hardware installed",
Toast.LENGTH_LONG).show();
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
Toast.makeText(getActivity(), "Biometric hardware unavailable.",
Toast.LENGTH_LONG).show();
break;
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
Toast.makeText(getActivity(), "No biometrics enrolled", Toast.LENGTH_LONG).show();
break;
}
return false;
}
在 Pixel 2XL 上,它返回BIOMETRIC_SUCCESS
指纹生物识别,但对于 Pixel 4XL,它返回BIOMETRIC_ERROR_HW_UNAVAILABLE
。