DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How to Add Fingerprint Authentication to Your App

Fingerprint authentication is quick and safe. Learn the steps for implementing it in your mobile application with this tutorial.

Cray Styris user avatar by
Cray Styris
·
Oct. 24, 17 · Tutorial
Like (1)
Save
Tweet
Share
11.95K Views

Join the DZone community and get the full member experience.

Join For Free

In this tutorial, we will show you how to add fingerprint authentication to your app.

What are the advantages of fingerprint authentication?

  • Fast and easy to use

  • Secure: fingerprint uniquely identifies you

  • Online transactions are safer

How to implement fingerprint authentication in your app:

  • Verify that the lock screen is secure, or in other words, it is protected by a PIN, password, or pattern.

  • Verify that at least one fingerprint is registered on the smartphone.

  • Get access to the Android keystore to store the key used to encrypt/decrypt an object.

  • Generate an encryption key and cipher.

  • Start the authentication process.

  • Implement a callback class to handle authentication events.

These are several steps to follow to enable fingerprint authentication. But still, you have to write lots of code to implement that.

Well, here is an easy way to implement this in your app by writing 5 – 10 lines in your code.

I have created a module library which will do all of the above for you, and by writing very little code, you can implement fingerprint authentication in your app in just five minutes and in any way you want.

Follow these steps:

Step 1) Add Dependency to Gradle

Add this dependency to your module's Gradle file:

implementation 'com.sa.hardik:fingerprintauthentication:0.1'

Step 2) Implement Callback

You can either implement this in your class and override the methods, or you can pass it as a constructor parameter.

Class MainActivity: AppcompactActivity(), FingerprintHandlerCallback {……

 override fun success() {
  //Todo on successful fingerprint authentication
 }

 override fun error(errorMsg: String) {
  //Todo on error in fingerprint authentication
 }

}

Step 3) Initialize the Fingerprint Authentication

val fManager = FingerprintManagerHelper(context, "MYKEY", callback)
fManager.initFingerprint()

Here,
context - Context reference of your activity or application
MYKEY - Encryption KEY
Callback - Reference of‘ FingerprintHandlerCallback’ implemented in library to get
success and error callback

That’s it! You have successfully implemented the fingerprint authentication in your app. You can use the same for payment authentication as well.

You can download the full demo from this GitHub URL.

Note: There are many devices which do not have a fingerprint sensor. In that case, you will receive an error callback at the time of initialization.

authentication app

Published at DZone with permission of Cray Styris. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • ChatGPT Prompts for Agile Practitioners
  • Top 10 Secure Coding Practices Every Developer Should Know
  • Top 5 Node.js REST API Frameworks
  • 5 Factors When Selecting a Database

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: