Recently with the release of Android 6.0 (M) last year, there has been a significant amount of changes to the APIs, one of them is Fingerprint Authentication. With the release of new APIs, authenticating users with help of fingerprint sensors on various devices is possible.
Following tutorial example shows how to implement Fingerprint Authentication in your application.
To authenticate users using the fingerprint sensor, you need to get an instance of the newly implemented FingerprintManager class and call the authenticate() method. However your app must be running on a compatible device which includes a fingerprint sensor. Moreover you must implement the user interface for the fingerprint authentication flow on your app, and use the standard Android fingerprint icon in your UI. Note that If you are developing multiple apps that use fingerprint authentication, each app must authenticate the user’s fingerprint separately.
Advantages of Using Fingerprint Authentication
1. Doesn’t matter how sick you are or unable to recollect things, your fingerprint still stays faultless as your identity and can never be misplaced.
2. Fast , Convenient and Reliable to use.
3. Unique fingerprints assure that it’s unlocked just by you.
4. With the help of Fingerprint authentication, online transactions become more convenient, hence your just a tap away from getting verified.
Here is the final app we are about to build.
1. Creating New Project
1. Create a new project in Android Studio from File ⇒ New Project and set the minimum SDK version to Android 6.0 (API 23).
2. Since we are going to work with Fingerprint authentication, we need to add USE_FINGERPRINT permission to AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="info.androidhive.fingerprint"> <uses-permission android:name="android.permission.USE_FINGERPRINT" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".FingerprintActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
3. Open colors.xml file located under res ⇒ values and update the file.
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#263237</color> <color name="colorPrimaryDark">#1e282d</color> <color name="colorAccent">#1e282d</color> <color name="textPrimary">#f5f5f5</color> <color name="textPrimaryDark">#95aab4</color> <color name="errorText">#ff7878</color> </resources>
4. Open strings.xml file located under res ⇒ values and update the file.
<resources> <string name="app_name">Fingerprint</string> <string name="title_activity_main">MainActivity</string> <string name="title_fingerprint">One-touch Sign In</string> <string name="desc_fingerprint">Please place your fingertip on the scanner to verify your identity</string> <string name="note">(Fingerprint sign in makes your app login much faster. Your device should have at least one fingerprint registered in device settings)</string> <string name="title_activity_home">Fingerprint</string> <string name="activity_home_desc">You have successfully logged in with fingerprint authentication</string> <string name="activity_home_note">Close and re-open the app to see the fingerprint auth screen again</string> </resources>
5. Create the fingerprint icon with the help of “Android Image Assets”. To do so, Right click on the drawable folder and Create a New ⇒ Image Asset named ic_action_fingerprint
2. Creating Fingerprint Activity
6. Create a layout xml file named activity_fingerprint.xml and place the below code.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_fingerprint" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorPrimary" tools:context="info.androidhive.fingerprint.FingerprintActivity"> <LinearLayout android:layout_width="match_parent" android:id="@+id/headerLayout" android:orientation="vertical" android:gravity="center" android:layout_marginTop="100dp" android:layout_height="wrap_content"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@drawable/ic_action_fingerprint" android:id="@+id/icon" android:paddingTop="2dp" android:layout_marginBottom="30dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/textPrimary" android:textSize="24sp" android:text="@string/title_fingerprint" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="20dp" android:layout_marginBottom="10dp"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/textPrimary" android:textSize="16sp" android:textAlignment="center" android:gravity="center" android:id="@+id/desc" android:text="@string/desc_fingerprint" android:layout_margin="16dp" android:paddingEnd="30dp" android:paddingStart="30dp"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/errorText" android:textSize="14sp" android:textAlignment="center" android:id="@+id/errorText" android:paddingEnd="30dp" android:paddingStart="30dp" android:layout_marginTop="30dp" android:gravity="center"/> </LinearLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/textPrimaryDark" android:textSize="14sp" android:text="@string/note" android:layout_marginLeft="16dp" android:textAlignment="center" android:layout_marginRight="16dp" android:layout_marginBottom="26dp" android:layout_alignParentBottom="true"/> </RelativeLayout>
7. Create an Android Activity class and name it FingeprintActivity.java. The following class includes various methods and functions like, onCreate() method that inflates activity_fingerprint.xml.
> generateKey() function which generates an encryption key which is then stored securely on the device.
> cipherInit() function that initializes the cipher that will be used to create the encrypted FingerprintManager.
> CryptoObject instance and various other checks before initiating the authentication process which is implemented inside onCreate() method.
Add the following final code of Finagerprint Actvity to the FinagerprintActvity.java file.
package info.androidhive.fingerprint; import android.Manifest; import android.annotation.TargetApi; import android.app.KeyguardManager; import android.content.pm.PackageManager; import android.hardware.fingerprint.FingerprintManager; import android.os.Build; import android.security.keystore.KeyGenParameterSpec; import android.security.keystore.KeyPermanentlyInvalidatedException; import android.security.keystore.KeyProperties; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; public class FingerprintActivity extends AppCompatActivity { private KeyStore keyStore; // Variable used for storing the key in the Android Keystore container private static final String KEY_NAME = "androidHive"; private Cipher cipher; private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fingerprint); // Initializing both Android Keyguard Manager and Fingerprint Manager KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE); textView = (TextView) findViewById(R.id.errorText); // Check whether the device has a Fingerprint sensor. if(!fingerprintManager.isHardwareDetected()){ /** * An error message will be displayed if the device does not contain the fingerprint hardware. * However if you plan to implement a default authentication method, * you can redirect the user to a default authentication activity from here. * Example: * Intent intent = new Intent(this, DefaultAuthenticationActivity.class); * startActivity(intent); */ textView.setText("Your Device does not have a Fingerprint Sensor"); }else { // Checks whether fingerprint permission is set on manifest if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { textView.setText("Fingerprint authentication permission not enabled"); }else{ // Check whether at least one fingerprint is registered if (!fingerprintManager.hasEnrolledFingerprints()) { textView.setText("Register at least one fingerprint in Settings"); }else{ // Checks whether lock screen security is enabled or not if (!keyguardManager.isKeyguardSecure()) { textView.setText("Lock screen security not enabled in Settings"); }else{ generateKey(); if (cipherInit()) { FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher); FingerprintHandler helper = new FingerprintHandler(this); helper.startAuth(fingerprintManager, cryptoObject); } } } } } } @TargetApi(Build.VERSION_CODES.M) protected void generateKey() { try { keyStore = KeyStore.getInstance("AndroidKeyStore"); } catch (Exception e) { e.printStackTrace(); } KeyGenerator keyGenerator; try { keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore"); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new RuntimeException("Failed to get KeyGenerator instance", e); } try { keyStore.load(null); keyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT) .setBlockModes(KeyProperties.BLOCK_MODE_CBC) .setUserAuthenticationRequired(true) .setEncryptionPaddings( KeyProperties.ENCRYPTION_PADDING_PKCS7) .build()); keyGenerator.generateKey(); } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException | CertificateException | IOException e) { throw new RuntimeException(e); } } @TargetApi(Build.VERSION_CODES.M) public boolean cipherInit() { try { cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { throw new RuntimeException("Failed to get Cipher", e); } try { keyStore.load(null); SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null); cipher.init(Cipher.ENCRYPT_MODE, key); return true; } catch (KeyPermanentlyInvalidatedException e) { return false; } catch (KeyStoreException | CertificateException | UnrecoverableKeyException | IOException | NoSuchAlgorithmException | InvalidKeyException e) { throw new RuntimeException("Failed to init Cipher", e); } } }
3. Creating Home Activity
8. Create the Activity by right-clicking your Project, New ⇒ Activity ⇒ Basic Activity and update the following files as shown below.
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="info.androidhive.fingerprint.HomeActivity"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_home" /> </android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/content_home" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="info.androidhive.fingerprint.HomeActivity" tools:showIn="@layout/activity_home"> <TextView android:layout_width="match_parent" android:text="@string/activity_home_desc" android:layout_centerVertical="true" android:textSize="24sp" android:textAlignment="center" android:textColor="@color/colorPrimary" android:layout_height="wrap_content" /> <TextView android:layout_width="match_parent" android:text="@string/activity_home_note" android:layout_alignParentBottom="true" android:textSize="14sp" android:textAlignment="center" android:textColor="@color/colorPrimary" android:layout_height="wrap_content" android:layout_marginBottom="24dp"/> </RelativeLayout>
package info.androidhive.fingerprint; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; public class HomeActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } }
4. Creating Fingerprint Authentication Handler Class
9. Create a class and name it FingerprintHandler.java. The Handler class extends FingerprintManager.AuthenticationCallback and includes some additional modules. Replace the following set of codes with any existing codes on FingerprintHandler.java file.
package info.androidhive.fingerprint; import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.fingerprint.FingerprintManager; import android.os.CancellationSignal; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.widget.TextView; /** * Created by whit3hawks on 11/16/16. */ public class FingerprintHandler extends FingerprintManager.AuthenticationCallback { private Context context; // Constructor public FingerprintHandler(Context mContext) { context = mContext; } public void startAuth(FingerprintManager manager, FingerprintManager.CryptoObject cryptoObject) { CancellationSignal cancellationSignal = new CancellationSignal(); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } manager.authenticate(cryptoObject, cancellationSignal, 0, this, null); } @Override public void onAuthenticationError(int errMsgId, CharSequence errString) { this.update("Fingerprint Authentication error\n" + errString, false); } @Override public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { this.update("Fingerprint Authentication help\n" + helpString, false); } @Override public void onAuthenticationFailed() { this.update("Fingerprint Authentication failed.", false); } @Override public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { this.update("Fingerprint Authentication succeeded.", true); } public void update(String e, Boolean success){ TextView textView = (TextView) ((Activity)context).findViewById(R.id.errorText); textView.setText(e); if(success){ textView.setTextColor(ContextCompat.getColor(context,R.color.colorPrimaryDark)); } } }
5. Testing the Project
Testing on a Physical Device
With the project now complete, debug the app on a physical Android device by placing your fingertip on the fingerprint scanner. If Fingerprint Authentication is succeed, user will be taken to the Home Activity as shown below.
Testing on an Emulator
You could also test the app on an emulator:
> Install Android SDK Tools Revision 24.3, if you have not done so.
> Enroll a new fingerprint in the emulator by going to Settings ⇒ Security ⇒ Fingerprint, then follow the enrollment instructions.
> Use an emulator to emulate fingerprint touch events with the following command. Use the same command to emulate fingerprint touch events on the lockscreen or in your app.
adb -e emu finger touch <finger_id>
On Windows, you may have to run telnet 127.0.0.1
Information Technology graduate from Maldives, currently making way towards a Doctorate in Information Technology. I enjoy meeting new people and finding ways to help them have an uplifting experience. I have had a variety of experience in Web Development and Mobile Application Development.
Thank you! Another useful tutorial 🙂 Just note that FinagerprintHandler.class code doesn’t open the HomeActivity after a successful fingerprint reading.
Yes, it seems. I’ll update the code. Thanks for pointing that out.
Hello sir plz update does “doesn’t open the HomeActivity after a successful fingerprint reading”
and notify me alokrajsingh255@gmail.com
Hello Ravi, Did you update the code? Thanks in advance
I’ll update the code. Thank You.
Hello Sharif, did u update the code? thanks in advance
Hey Ravi, thanks for sharing this tutorial. I have one doubt related to
Service. that is when my app closes my background service runs but when i
removed it from my task manager then the background Service also
Stops.So if i want to start that service then what i do for that.
Because my push notification are also not receives with this kind of
issue, Please Kindly help. 🙂
Why are you removing the app from Task Manager?
Thanks for the reply Ravi..i am using Redmi 3s prime phone and for cleaning the RAM i am removing app from task manager. I am also removing whatsapp and facebook app from my task manager, but after that i get message from both whatsapp and facebook , but not from my app, So how whatsapp and facebook start their service even after i removed it from task manager?
Please help ravi, its burning issue for me, and it will help other developers too…
What is service you are using to receive the message. Push notification?
GCMBaseIntentService
I guess GCM service won’t be killed as it runs as google service. Have a look at below links
http://stackoverflow.com/questions/31981275/why-gmail-yahoo-whats-app-service-is-not-getting-killed
http://stackoverflow.com/questions/10671460/restart-the-service-even-if-app-is-force-stopped-and-keep-running-service-in-bac
Also try using Firebase instead of GCM.
If GCM service won’t be killed then i would get the push notifications, but i would not. if i not removed my app from task manager then, i am getting push notifications, but when i remove my app then push notification does not arrives.
I have see why this is happening?
That is also big mystery for me. Please see if you could help.
in Redmi Phones ( Based on MIUI) You Have to Give Permission for Auto start the app So You can get Push notifications when App is clear from memory
so for that Go to Security > Permission > AutoStart and select your app and turn On auto start for that and after that you will be able to receive Push.
Note : MIUI have default auto start on for Facebook , Whats app etc as they are popular apps so MIUI takes care of that so basically concept is that if any app have auto start permission by MIUI then its able to receive push when its not in stack
if you turn off auto start for Facebook , Whatsapp then they will also not able to receive push
hi sir i want ask one question that’s how to sensor used associated with api for give information using fingerprint like a Adhar card etc…
and what should need of resourses …..such as device etc…
Please see if you could help.
hi sir i want ask one question that’s how to sensor used associated with api for give information using fingerprint like a Adhar card etc…
and what should need of resourses …..such as device etc…
Please see if you could help.
Thank you Ravi for the tutorial. The tutorial got some typo errors . BTW are you using any patterns for the development, like MVP, MVVM or any other if so please provide a simple tutorial on that.
Hi Renitto
Could you point out the typo errors. I’ll correct them. I am not using any MVP or other models as of now.
FingerprintActivity / FinagerprintActvity.java
There is one more typo error at step 7 (Fingeprint)
Hi Renitto,
Could you please highlight those errors 🙂
Sir, Can you please suggest me some latest android books (2016) covering latest technologies ?
Thank you Ravi for the tutorial. I had One doubt, That is what kind of data we can get after authentication (“onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)”)
and we will store the result in to database. How We can Use it For Real time Applications For authentication. does it will generate a unique id for each user..
Android system doesn’t allow users to save fingerprints remotely. Fingerprints are stored in a secure place by android and are not accessible.
“Thus, raw images and processed fingerprint features must not be passed in untrusted memory. All such biometric data needs to be secured within sensor hardware or trusted memory. (Memory inside the TEE is considered as trusted memory; memory outside the TEE is considered untrusted.)” – Android
Thanks Ravi for the tutorial,, but when i tried to add Fingerprint in a Service , i got an error
is there anyway to add fingerprint auth in Service ?
What’s the error?
i am getting a toast message saying ” Fingerprint Authentication error fingerprint operation canceled”
hello i wanna be to save the finger touch in sqlite database
Android doesn’t allow users to save fingerprints remotely. Fingerprints are stored in a secure place by android and are not accessible.
“Thus, raw images and processed fingerprint features must not be passed in untrusted memory. All such biometric data needs to be secured within sensor hardware or trusted memory. (Memory inside the TEE is considered as trusted memory; memory outside the TEE is considered untrusted.)” – Android
nice
how to get scanned fingerprint name after Authentication Succeeded ??
@Ravi Tamada:disqus Is Fingerprint provide any unique code for specific scanned fingerprint or Fingerprint name which is show on settings->secure->fingerprint ?
The app that you shared is not opening.
It says “Unfortunately, Fingerprint has stopped.”
I’m using Coolpad Note 3 Lite, running Android 6.0 with a fingerprint sensor.
Thanks @Ravi Tamada:disqus for this tutorial. I have been able to successfully implement it. I just wanna know, is there anyway i can get the scanned fingerprint result and save elsewhere?
Also, at certain times, my sensor seems to be blocked (not onAuthenticationError) until a few tries. This always happens just when i use the app i built from this tutorial. I am using a Oneplus 3
Android doesn’t allow users to save fingerprints remotely. Fingerprints are stored in a secure place by android and are not accessible.
“Thus, raw images and processed fingerprint features must not be passed in untrusted memory. All such biometric data needs to be secured within sensor hardware or trusted memory. (Memory inside the TEE is considered as trusted memory; memory outside the TEE is considered untrusted.)” – by Android
How do you make an app to register a user using fingerprint auth, and be able to BAN the user by this same method? I would love to have the option to BAN users Permanently by fingerprint auth. Is this possible or do you know a workaround that can achieve this?
Thanks!
There are no workaround, at least nothing that I know. Also you should’t try to sync fingerprint data to cloud.
how to list all fingerprints name?
did u get it to redirect to the homeActivity page?
After :
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
this.update(“Fingerprint Authentication succeeded.”, true);
//add this code:
Intent i = new Intent(context, HomeActivity.class); //Replace HomeActivity with the name of your activity
context.startActivity(i);
//Hope this help
}
but it give error…. RuntimeException : Unable to start activity componentinfo
@Ravi Tamada:disqus can I add fingerprint data in sql or firebase datatbase and can I use tht data for authentications .eg. I need to verify the fingerprints from adhar card and the data I am giving ..
please rply soon ..
Syncing fingerprint data to cloud is not supported by Android.
“Thus, raw images and processed fingerprint features must not be passed in untrusted memory. All such biometric data needs to be secured within sensor hardware or trusted memory. (Memory inside the TEE is considered as trusted memory; memory outside the TEE is considered untrusted.)” – by Android
Thanks Sharif.
Hello guys,
Thank you for great tutorial. I have a quick question if you guys don’t mind answering. How do i restrict fingerprint authentication to be used on single activity. currently i is running on every single activity of my app.
Thanks.
Hello My phone is not support finger print.
Is there any other alternative. ? how to achieve this authentication without sensor ?
Thank you very much for wonderful tutorial. I want to use php mysql login authentication with fingerprint reader with android app please help to implement this.
How to display the finger scan results based on the id, the example displays the results of a different finger scan, so each finger d scan and display the scan results
Hey Ravi, this doesn’t work on Samsung galaxy s5, after the app launches,it says my device doesnt have a finger print sensor, any ideas?
samsung has ts own fingerpnt API calld Pass. Android’s API doesn’t work.
Are you using it with the external fingerprint device for it…?@RaviTamda
how can i use external bio-metric device for fingerprint?
What is use of gerateKey, cipherObject etc? and which Samsung devices do not support Android’s Fingerprint API?
how to encrypt something after we got to the HomeActivity ? how to take the key or cipher that already initialized before on FingerprintActivity ?
Hello
I want to adding new fingertip on my application how to add new finger to authentication via the scanner
Doesn’t work with Samsung S5 😉
The generateKey() and cipherInit() parts are not needed in this example. This example only authenticates the user through fingerprint and shows some static content. It does not use the key from generateKey() and cipher from cipherInit() at all.
For demonstration of fingerprint authentication, we can simply pass null as the crypto object in fingerprintManager.authenticate() like this fingerprintManager.authenticate(null, null, 0, callback, null); If we need to use the key after successful authentication, we then need to pass a crypto object.
I was confused about the generateKey() and ciperInit() parts at first and took me some time to realized that they are not needed for the purpose of this app.
Thanks Jerry for your valuable findings. @sharifkhaleel might have some inputs for you.
I want to create an android application which can read finger print of user from OTG finger print scanner.
How can i proceed?
Please help..
How can i take input fingerprint and save to database and check when i needed . please help me
Thanks for the tutorial. I have tried in sample. I have a doubt in this. In my device i registered three fingerprint. How can i get the exact authenticated fingerprints data.
will this code work for external thumb scanner attached to mobile using cable
no this code doesn’t work for external scanner devices.
very cool stuff you have done…really it is interesting…thankyou sir
You are welcome 🙂
nice code..but how to implement it in case of service?
Sir, i am trying to add fingerprint authentication in my app. I have Coolpad note 3 lite mobile which support fingerprint authentication and it is running on Android version 5.1 Lollipop. But the problem is how can i authenticate fingerprint in it. I have seen Android Developers Documentation they said it is possible only on devices running on Marshmallow or above. So how can i do it on my Device..
How can i take input fingerprint and save to database and check when i needed . please help me
Is any possible way to use device face authentication to unlock the app
How to handle Too Many Attemps ?
write this method in FingerprintHandler:
public void completeFingerAuthentication(FingerprintManager fingerprintManager, FingerprintManager.CryptoObject cryptoObject){
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return;
}
try{
fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}catch (SecurityException ex) {
Log.d(“Error”, “An error occurred:n” + ex.getMessage());
} catch (Exception ex) {
Log.d(“Error”, “An error occurredn” + ex.getMessage());
}
}
After this take instance of FingerprintHandler and intialize it as follows :
fingerprintHandler = new FingerprintHandler(this); inside onCreate
and call fingerprintHandler.completeFingerAuthentication(fingerprintManager, cryptoObject); inside onCreate and onResume of activity
in my case it worked only once ,when i tried from main activity it didnt worked what is the solution for that?
where is the the intent to the next activity cant find it in the code??
Its there in the code we download but not there here in the tutorial
how to open next activity with fingerprint scanner i did not get code from this.????
Hi, Sharif Khaleel
How can i implement it in minsdkversion below api level 23
Yes you can. Instead of FingerprintManager class you’ll have to use FingerprintManagerCompat
@Ravi Tamada:disqus @sharifkhaleel:disqus hello guys, thank you for what you have done so far. androidhive is one of the best resources of mine for me. I am curious about one thing, I am trying to build an application which has a fingerprint auth option. Let’s say someone authorized from phone A with fingerprint, and wants to login from phone B with same fingerprint. Is this possible somehow? May I save fingerprint information to somewhere else like DB?
Why fingerprintManager.isHardwareDetected() is always return true. Please Help
Mention ! before starting within condition
if(!fingerprintManager.isHardwareDetected()){
}
Nice tutorial. Is it possible to unlock app using face authentication ? If yes,can you share?
can i register a new fingerprint in my own aplication without going to settings?
thanks you for this brilliant toturial
if I wantedto use a physical fingerprint module powerd by an arduino uno how wod i implement this
its not going forward after press on fingerprint scanner and never show any toast
Download apk link unavailable