我被要求根据生物识别硬件的存在显示某些UI元素.对于Android 23-27我使用FingerprintManager#isHardwareDetected()和FingerprintManager#hasEnrolledFingerprints().这两个都在Android 28中被弃用.
我明白,我可以用得到这个信息BiometricPrompt#authenticate(...),并在接受BiometricPrompt#BIOMETRIC_ERROR_HW_NOT_PRESENT或BiometricPrompt#BIOMETRIC_ERROR_NO_BIOMETRICS在BiometricPrompt.AuthenticationCallback#onAuthenticationError(int errorCode, ...)方法.但这会导致BiometricPrompt在支持设备上显示,这是不希望的.使用它CancellationSignal似乎也不是解决方案,因为我不知道何时取消提示.
有没有办法检测生物识别硬件的存在和用户注册?