Pages

Wednesday, May 25, 2016

How to check FingerPrint feature available in android?

In android API 23 added Finger Print feature for lock or unlock your phone, authorize purchases, or sign in to apps.
So how to check fingerprint feature available or not in android device? check below.

Method 1 :
  if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
      Toast.makeText(this, "Finger print not supported", Toast.LENGTH_SHORT).show();
  }

Method 2 :
 
   FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
   if (!fingerprintManager.isHardwareDetected()) {
       // Device doesn't support fingerprint authentication
       Toast.makeText(this, "Device doesn't support fingerprint authentication", Toast.LENGTH_SHORT).show();
   } else if (!fingerprintManager.hasEnrolledFingerprints()) {
       // User hasn't enrolled any fingerprints to authenticate with
      Toast.makeText(this, "User hasn't enrolled any fingerprints to authenticate with", Toast.LENGTH_SHORT).show();
   } else {
      // Everything is ready for fingerprint authentication
      Toast.makeText(this, "Everything is ready for fingerprint authentication", Toast.LENGTH_SHORT).show();
   }

This method required USE_FINGERPRINT permision. Add in Menifest file.
    
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
Thank you :)