gpt4 book ai didi

android - 确定是否存在生物识别硬件以及用户是否已在 Android P 上注册生物识别

转载 作者:IT老高 更新时间:2023-10-28 21:52:56 33 4
gpt4 key购买 nike

我被要求根据生物识别硬件的存在显示某些 UI 元素。对于 Android 23-27,我使用 FingerprintManager#isHardwareDetected()FingerprintManager#hasEnrolledFingerprints() .两者在 Android 28 中均已弃用。

我知道我可以使用 BiometricPrompt#authenticate(...) 获取此信息并接收BiometricPrompt#BIOMETRIC_ERROR_HW_NOT_PRESENTBiometricPrompt#BIOMETRIC_ERROR_NO_BIOMETRICSBiometricPrompt.AuthenticationCallback#onAuthenticationError(int errorCode, ...)方法。但这会导致 BiometricPrompt显示在支持设备上,这是不可取的。使用 CancellationSignal似乎也不是解决方案,因为我不知道何时取消提示。

有没有办法检测生物识别硬件的存在和用户注册?

最佳答案

Google 终于用 Android Q 解决了这个问题

android.hardware.biometrics.BiometricManager#canAuthenticate()方法可用于确定是否可以使用生物识别技术。

该方法可用于确定是否存在生物识别硬件以及用户是否已注册。

Returns BIOMETRIC_ERROR_NONE_ENROLLED if the user does not have any enrolled, or BIOMETRIC_ERROR_HW_UNAVAILABLE if none are currently supported/enabled. Returns BIOMETRIC_SUCCESS if a biometric can currently be used (enrolled and available).

希望将其添加到 androidx.biometric:biometric 库中,以便可以在所有设备上使用。

在此之前,@algrid 的解决方案可用于确定生物识别注册。

以下可用于确定是否存在指纹读取器。

Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
context.packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)

关于android - 确定是否存在生物识别硬件以及用户是否已在 Android P 上注册生物识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50968732/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com