RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
C++DelphiTech Partner

Efficiently Manage KeyguardManager API in your Delphi FireMonkey Android Projects

When you start an enterprise-level project you need to integrate authentication options into your projects and at that time you can use Android Built-in APIs, for instance, KeyguardManager API which can be used to lock and unlock the keyguard in your Delphi or C++ Builder FireMonkey Android application.

To handle this API from your FireMonkey project we can utilize Authentication for Android library by WINSOFT. This library is available for Delphi/C++ Builder 10 – 10.4 and it uses Android KeyguardManager API. So in this library, we have the TAuthentication class which is an essential class to handle confirming credentials. This is a commercial library that has a trial version with all features for evaluation only and if you wish to distribute Authentication for Android library as part of your Android application, you must register a license. 

This is the class structure here:

Let’s see how we can implement this class in our real project. The first step is to install this library into our IDE. You can follow the tutorial here to install the library correctly.

The second step is adding the unit name into the uses section.

Add the aAuthentication unit into the uses section.

And now we should declare 2 procedures, one for OnSuccess event and one for OnError event for triggering the events. Moreover, we need an instance of a TAuthentication class, so here I will declare them in the scope of the private declaration.

Result:

Now let’s see our UI for this project.

As you can see this is simple, we have a button for confirming credentials, a memo for showing messages, and a label which is not visible because, in this project, the label shows a message when you have a valid confirmation.

The next is implementing OnSuccess and OnError events.

The next step is to create the OnCreate event on TForm and initialize the Authentication instance, setting OnError & OnSuccess notify events and also check if the device is secured or not.

With the DeviceSecured property, we can get whether the device is secured with a PIN, password, pattern, or biometrics.

Everything looks good so now we can call the ConfirmCredentials procedure on button click event.

The ConfirmCredentials procedure gets an intent to prompt the user to confirm credentials (pin, pattern, password,  or biometrics if enrolled) for the current user of the device.

That is all it takes to implement KeyguardManager API in your FireMonkey Android project. I would recommend that you watch the demo action video below to see the result easily.

  • Works with: Delphi & C++Builder 10 – 10.4
  • Works on: Android 32-bit & Android 64-bit

Like what you see? You can get Authentication for Android and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4 today!


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Deep Dive Webinar: Boost C++Builder Compile Speed with TwineCompile
About author

Software Developer | B.Tech-CSE at AUT | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified | Udacity Alumni
Related posts
CodeDelphiRAD Studio

Learn About How To Redirect Inserting, Deleting And Updating Records In Delphi With FireDAC

CodeDelphi

Quickly Build Enterprise-Grade Multi-Tier Solutions Using DataSnap In Delphi And C++

C++CodeDelphi

Easily Create A Python Container Type In Delphi And Execute It In This Windows Sample App

C++DelphiRAD Studio

Manual uninstall of RAD Studio/Delphi/C++Builder 10.4 Sydney

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES