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

Convert any Android API to Delphi and C++ Builder units to utilize in your FireMonkey Android Projects

Intro

When it comes to Cross-Platform application development frameworks, you get all the tools you need to create whatever you want. You can shape that framework and create new development tools for yourself by using or expanding the framework itself. Take the FireMonkey framework, for example. If you don’t have access to third-party APIs, you can convert them into Delphi or C++ Builder units. The FireMonkey provides you with essential helper units to help you expand it yourself.

To automate the conversion process, you can utilize the JavaImport for the Android tool by WINSOFT. This tool is commercial, and there is a trial version that can convert .jar or .class files into usable Delphi & C++ Builder units. But there is a limit. If you would like to turn Android APIs into Delphi or C++ Builder, you need to get a license.

Specifications

  • Supported OSs: Android 32 & Android 64
  • Available for Delphi & C++ Builder 6-10.4

How to use it?

We recommend that you watch our action video about this tool, which shows how to convert .class file into .pas file with one command. It also demonstrates the result of the generated files in a real application.

Let’s investigate how we can use the converted android.widget.Toast API. As an example, there is the android.widget.Toast.pas unit. First, you should add the module to the uses list.

As you can see, everything is converted to Object Pascal code. 

Here is the implementation:

If you pay attention to the code, there is compiler level conditional if the compiler version is less than 32, which means not Sydney, Rio, and Tokyo versions, it executed code in using the CallInUiThread procedure. This procedure is deprecated now, and this was an essential procedure to handle launching activities and handling results. In newer versions, all code is currently running in the Java UI Thread, removing the need for thread synchronization.

Then we are calling the TJToast with JavaClass, which bridges the units. And also, you should always pay attention to the type of conversion.

Next, with the help of ShowToast, you’ll learn how to get battery level from your FireMonkey Android project.

  • First, bridging the TJIntentFilter interface.
  • Registering the receiver using the JFMXNativeActivity
  • Then takes the EXTRA_LEVEL and EXTRA_SCALE properties
  • Using the ShowToast displays the battery level.

Remember to check out the demonstration video above.

Head over and check out the full WINSOFT JavaImport tool.

Are you interested in converting android APIs in your android projects with the Cross-Platform Development tool, which will assist you in developing apps in the Delphi or C++ environments?
You can get the JavaImport Tool 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!


Coding Boot Camp

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
Related posts
CodeDelphiHow-To'sTech Partner

How To Implement Push Notifications In Cross Platform Apps

C++DelphiHow-To'sIDERAD StudioWindows

Windows 10 Apps Development Tutorial for Beginners

IDERAD Studio

What Is An IDE?

DelphiEventNews

Coding BootCamp 2022

Leave a Reply

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

IN THE ARTICLES