如何检查android系统指纹认证设备的兼容性 [英] How to check device compatibility for finger print authentication in android
问题描述
我与指纹认证采用了android 6.0的API工作。
我的要求是,如果当前设备是支持指纹验证,那么我将通过其他指纹认证将采用正常方式登录该应用程序。
因此,任何人能告诉我,如何检查android系统指纹认证设备兼容。
先谢谢了。
您必须在 FingerprintManager
isHardwareDetected >类。
确定是否指纹硬件是present和功能。返回
真,如果硬件present和功能,否则为false。
块引用>//检查是否我们在Android 6.0(M)上运行或更高版本
如果(Build.VERSION.SDK_INT> = Build.VERSION_ codeS.M){
//仅适用于从6.0的Android API指纹(M)
FingerprintManager fingerprintManager =(FingerprintManager)context.getSystemService(Context.FINGERPRINT_SERVICE);
如果(!fingerprintManager.isHardwareDetected()){
//设备不支持指纹认证
}否则如果(!fingerprintManager.hasEnrolledFingerprints()){
//用户没有登记任何指纹进行身份验证
}其他{
//一切都准备好了指纹认证
}
}不要忘了添加权限访问AndroidManifest指纹功能:
<使用许可权的android:NAME =android.permission.USE_FINGERPRINT/>
I am working with finger print authentication using android 6.0 api. My requirement is, if current device is supports finger print authentication, then I will go through finger print authentication else will use normal way to login the application.
So, any one can tell me, how to check device compatibility for finger print authentication in android.
Thanks in advance.
解决方案You have to use method
isHardwareDetected
onFingerprintManager
class.Determine if fingerprint hardware is present and functional. Returns true if hardware is present and functional, false otherwise.
// Check if we're running on Android 6.0 (M) or higher if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { //Fingerprint API only available on from Android 6.0 (M) FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE); if (!fingerprintManager.isHardwareDetected()) { // Device doesn't support fingerprint authentication } else if (!fingerprintManager.hasEnrolledFingerprints()) { // User hasn't enrolled any fingerprints to authenticate with } else { // Everything is ready for fingerprint authentication } }
Don't forget to add permission to access fingerprint functions in AndroidManifest:
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
这篇关于如何检查android系统指纹认证设备的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!