且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

指纹传感器高于6.0的设备未使用Android指纹SDK

更新时间:2023-02-17 18:33:05

您可以使用FingerprintManager进行检查,如

 如果(Build.VERSION.SDK_INT> = Build.VERSION_CODES.M){
FingerprintManager FingerprintManager =(FingerprintManager)context.getSystemService(Context.FINGERPRINT_SERVICE);
if(!fingerprintManager.isHardwareDetected()){
//设备不支持指纹API。通知用户。
}
}

和往常一样,您需要获得许可

 <使用权限android:name = android.permission.USE_FINGERPRINT /> 


I have implemented fingerprint authentication (of course with official Android fingerprint SDK!) in my app recently, some of my users have complained that they have fingerprint sensor (with Android 6.0) in their phone but unable to use the feature.

I have done some investigation on that, and I found that Samsung S5 and Note 4 devices have fingerprint sensor with 6.0 but they are not using the official Android fingerprint SDK.

My questions:

  1. Is anyone have the list of devices which uses their own fingerprint SDK.
  2. In this case, I would like to convey the user that your device is not supported by the app. Is there any reliable way I can programmatically find these devices("Devices with unsupported fingerprint sensor with 6.0 & above") and show the message?

You can check it with the FingerprintManager like

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
    if (!fingerprintManager.isHardwareDetected()) { 
        // Device doesn't support fingerprint api. Notify the user.
    }
}

and as usual, you'll need the permission

<uses-permission android:name="android.permission.USE_FINGERPRINT" />