FingerPrintManager
只涉及指纹验证数据,因此它有 hasEnrolledFringers()
。但是 BiometricPrompt
用于面部解锁、指纹和虹膜识别。它就像一个通用的管理类。
Google 已经在 Android Q 中添加了 canAuthenticate
支持。
但是您可以使用以下方法检查低版本 API:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
val hasBiometricFeature :Boolean = context.packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
无论如何,Google也将其添加到androidx组件中 androidx.biometric:biometric
最初的回答
implementation 'androidx.biometric:biometric:1.0.0-alpha04'
uses permission
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
on `AuthenticationCallback'
public void onAuthenticationError(int errorCode, CharSequence errString) {}
you can check the error codes with the ones
/**
* The user does not have any biometrics enrolled.
*/
int BIOMETRIC_ERROR_NO_BIOMETRICS = 11;