Implement Custom Android SDK Callback Events With Delphi XE5 Firemonkey On Android

Delphi XE6 Firemonkey Custom Android SDK EventsDeveloper Cristian Peta has a post up on the Embarcadero forum with some sample code showing how he implemented a bar code reader callback in the Android SDK for Delphi XE5 Firemonkey. Basically how Firemonkey applications work on Android is there is an Android SDK shim which is written in Java (and contained within the classes.dex file). This shim calls the actual Android NDK based Firemonkey application which is a .SO file (where your code is located). What Cristian Peta’s code does is implement some Java code and custom events in that Android SDK shim and those events make function calls into the Firemonkey application. This allowed him to implement a Honeywell SDK in Java and use it from Firemonkey. Brian Long pioneered this method in his CodeRage 8 sessions on the topic. Take a look at the BarCode and Menu demos in the AccessingTheAndroidAPI.7z download for complete examples of doing this. I am including Cristian Peta’s full post below with his implementation:

“My solution was to write some Java code then insert this code into classes.dex
Then I use this Java code from Delphi trough Java generic import and JNI.
You can read Brian Long blog about classes.dex

My starting point from Honeywell SDK examples was DecodeSampleActivity. There is ScanDemoMainActivity.java that I modified and merged into classes.dex
I extended com.embarcadero.firemonkey.FMXNativeActivity but I think now it should be enough to extend Activity. When you extend Activity you do not need to decompile classes.dex

The main Delphi part is here:”

[/crayon]

“And Java code:”

[/crayon]

One more thing (Java generic import):

[/crayon]

Best Regards,
Cristian Peta

For implementing existing third party SDKs like MoPub, TapJoy, Millennial Media, Google Play Services, Flurry, Chartboost, Upsight, or even new Bluetooth functionality for Android in Delphi XE5, Delphi XE6, and AppMethod this may be the fastest way.

Head over and download the samples from Brian Long on customizing your Firemonkey classes.dex file.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Implement Custom Android SDK Callback Events With Delphi XE5 Firemonkey On Android by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.

3 Responses to Implement Custom Android SDK Callback Events With Delphi XE5 Firemonkey On Android

  1. Pingback: Customize The Classes.dex File To Access Third Party Android JAR Libraries In Delphi XE6 Firemonkey | Delphi XE5 XE6 Firemonkey, Delphi Android, Delphi IOS

  2. Pingback: Implement A Dynamic Broadcast Receiver In Delphi XE6 & XE7 Firemonkey On Android | Delphi XE5 XE6 XE7 Firemonkey, Delphi Android, Delphi IOS

  3. Cody says:

    Hi, can anyone provide a Code Sample here without the faulty HTML-Stuff? Thanks

Leave a Reply

Show Buttons
Hide Buttons
Read previous post:
Delphi XE6 Firemonkey Morph A Polygon And Intersect A Line
Polygon Morphing And Line Intersection With Delphi XE6 Firemonkey On Windows And OSX

Developer zedalaye has a project up on Github which demonstrates how to intersect a polygon that is morphing in real time...

Close