Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++DelphiTech Partner

Efficiently Manage KeyguardManager API in your Delphi FireMonkey Android Projects

When you begin an enterprise-level project, you must integrate authentication options into your projects. At that point, you can use Android Built-in APIs, such as the KeyguardManager API, 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 use the WINSOFT Authentication for Android library. This library is available for Delphi/C++ Builder 10 – 10.4 and uses the Android KeyguardManager API. In this library, we have the TAuthentication class, which is required to handle credential confirmation. This is a commercial library with a trial version that includes all features for evaluation purposes only. If you want to distribute the 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

Do you want to manage your KeyguardManager API on your android projects with the use of IDE Software? 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

About author

Software Developer | CS(CyberSec) Undergrad at APU Malaysia | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified

Leave a Reply

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

IN THE ARTICLES