Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkey

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.

Related posts
AndroidC++BuilderDelphiDemoFiremonkeyWindows

Powerful Commercial Gorilla3D Framework Upgraded For Delphi FireMonkey On Windows And Android

AndroidC++BuilderCode SnippetDelphiDemoFiremonkeyIOSOSXShowcaseWindows

Powerful Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

Significant Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

C++BuilderDelphiIDEWindows

Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows

Sign up for our Newsletter and
stay informed

Leave a Reply to Cody Cancel reply