RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
TIME LEFT
12 13 hrs 07 08 mins 02 03 secs

Upgrade Pricing Extended to September 30

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 framework, you get all the tools to create what you want, you can shape that framework, you can create new development tools for yourself by using or expanding the framework itself. Take, for example, the FireMonkey framework. If the third-party APIs are not available, you can convert them into Delphi or C++ Builder units. The FireMonkey gives you essential helper units to 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.

Like what you see? 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!


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

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

Leave a Reply

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

IN THE ARTICLES