Using the Mobile SDK for Android to Enable a Fingerprint Scanner, Page 2
Start Using Mobile SDK for Android Features
You're now ready to start using the Mobile SDK for Android to verify your user's identity.
The methods you're interested in are part of the com.authentec.tsm package. Specifically, you want to use the TSM.LAP class methods to check if fingerprints are enrolled in the fingerprint database (that is, that fingerprint scanning is enabled on the device), and then if that's the case you'll want to prompt the user to swipe and verify their identity (or enter their associated numeric pin).
Check for Fingerprint Enrollment Prior to Verifying the User's Identity
The following method call checks to see if any fingerprints are enrolled in the fingerprint database on the device. You will always want to check this method before trying to verify the user's identity using the fingerprint reading SDK.
int iMap = com.authentec.tsm.TSM.LAP(CheckPointActivity.this).GetMap().exec();
Here we are assuming that this method is being called within the CheckPointActivity class. This method has three possible return values:
- A return value of
-1indicates an error.
- A return value of
0indicates that no fingerprints are registered in the database, so you probably don't want to continue using the SDK.
- Any other return value indicates a bit map flag where the first bit
b0signifies whether the database contains a record for the left pinky fingerprint,
b1corresponds to the left ring fingerprint, and so on, ending with
b9, which represents the right pinky fingerprint.
This is a blocking call that should be called off the main thread of your application, so that it remains responsive. See the sample source code provided with this tutorial for an example of how to do this, if you are unfamiliar with asynchronous operations on the Android platform. The following figure shows the sort of application screen flow you might use if you find that no fingerprints are enrolled in the database.
Prompting the User to Verify Their Identity
Once you know that the fingerprint database contains fingerprints, you can prompt the user to swipe their finger (or enter their associated pin code). The following method does just that.
int iResult = com.authentec.tsm.TSM.LAP(CheckPointActivity.this) .verify().viaGfxScreen("lap-verify") .exec();
Here we are assuming that this method is being called within the CheckPointActivity class. This method has two possible return values:
- A return value of
0indicates that the user has been verified successfully.
- Any other return value indicates that the user has not been verified successfully or there was an error. See the "AuthenTec Simple SDK for Android Programmers Manual" for a complete set of errors.
This is a blocking call that should be called off the main thread of your application, so that it remains responsive. See the sample source code provided with this tutorial for an example of how to do this, if you are unfamiliar with asynchronous operations on the Android platform. The following figure shows the sort of application screen flow you might use if you verify the user's identity successfully.
This concludes your brief tutorial on how to incorporate fingerprint reading technology into your Android applications using the Motorola ATRIX 4G. The Mobile SDK for Android is an effective way to provide simple user authentication checks within your Android applications. Should you need more sophisticated fingerprint reading functionality, you can register for and use the Advanced Mobile SDK for Android, also available through AuthenTec and Motorola's developer programs. Let us know about the exciting apps you're developing which use the fingerprint reader!
About the Authors
|Shane Conder and Lauren Darcey--Contributing Editors, Mobile Development--have coauthored two books on Android development: an in-depth programming book entitled Android Wireless Application Development (ISBN-13: 978-0-321-62709-4) and Sams Teach Yourself Android Application Development in 24 Hours (ISBN-13: 978-0-321-67335-0). When not writing, they spend their time developing mobile software at their company and providing consulting services.|
Page 2 of 2