android-fingerprint-authentication

Additional

Language
Java
Version
1.0.1 (Oct 31, 2016)
Created
Oct 7, 2016
Updated
Apr 7, 2018
Owner
Multidots Inc (multidots)
Contributor
Keval Patel (kevalpatel2106)
1
Activity
Badge
Generate
Download
Source code
APK file

Commercial

Fingerprint Authentication Helper

Finger print authentication helper is an android library to simplify the authentication with finger print process. This will provide a common platform for finger print authentication for all the android versions.

Screenshot

Dependency

  • Add the dependencies to your app level build.gradle file:
dependencies {
    compile 'com.multidots:fingerprint-auth:1.0.1'
}

Usage

  • Inside your activity or fragment create FingerPrintAuthHelper instance and call startAuth() in the onResume() to enable finger print scanning.
@Override
protected void onCreate(Bundle savedInstanceState) {
    mFingerPrintAuthHelper = FingerPrintAuthHelper.getHelper(this, this);
    //.... 
    //....        
}
   
@Override
protected void onResume() {
    super.onResume();
    //start finger print authentication
    mFingerPrintAuthHelper.startAuth();
}
  • Don't forget to disable the finger print scanner in onPause() of your activity/fragment.
@Override
protected void onPause() {
    super.onPause();
    mFingerPrintAuthHelper.stopAuth();
}

** Callbacks **

  • You need to implement FingerPrintAuthCallback in your activity/fragment to receive the callbacks from the helper class.
@Override
public void onNoFingerPrintHardwareFound() {
    //Device does not have finger print scanner.
}

@Override
public void onNoFingerPrintRegistered() {
    //There are no finger prints registered on this device.
}

@Override
public void onBelowMarshmallow() {
    //Device running below API 23 version of android that does not support finger print authentication.
}

@Override
public void onAuthSuccess(FingerprintManager.CryptoObject cryptoObject) {
    //Authentication sucessful.
}

@Override
public void onAuthFailed(int errorCode, String errorMessage) {
    switch (errorCode) {    //Parse the error code for recoverable/non recoverable error.
        case AuthErrorCodes.CANNOT_RECOGNIZE_ERROR:
            //Cannot recognize the fingerprint scanned.
            break;
        case AuthErrorCodes.NON_RECOVERABLE_ERROR:
            //This is not recoverable error. Try other options for user authentication. like pin, password.
            break;
        case AuthErrorCodes.RECOVERABLE_ERROR:
            //Any recoverable error. Display message to the user.
            break;
    }
}

Demo application

Here is the link to the demo application.

Questions?

  • If you have some problems with using this library or something doesn't work correctly, feel free to open an issue.

How to contribute?

Simple 3 step to contribute into this repo:

  1. Fork the project.
  2. Make required changes and commit.
  3. Generate pull request. Mention all the required description regarding changes you made.

Medium Article