1
votes

To work with USB-devices (on Android-devices having USB-host) one has to use BroadcastReceiver. I have found a demo (https://github.com/freeonterminate/delphi/tree/master/BroadcastReceiver). I have tested it on Delphi XE10. Wasted a lot of time to make it work until I discovered that demo works on XE7 but not on XE10.

"Interface not supported" error is occured during JFMXBroadcastReceiver creation (or near).

To demonstrate the problem I have created a brand new simple project https://github.com/ashumkin/Delphi-Android-BroadcastSample. It works in XE7 (press "Register" button to create a broadcast receiver which catches and logs (see adb logcat) screen locking/unlocking. But it does not work in XE10 - "Interface not supported" occurs. In logcat I can see

W/dalvikvm(31735): dvmFindClassByName rejecting 'com/embarcadero/firemonkey/broadcast/FMXBroadcastReceiverListener'
W/dalvikvm(31735): dvmFindClassByName rejecting 'com/embarcadero/firemonkey/broadcast/FMXBroadcastReceiver'

(but they are present in logcat of XE7-built app)

I tried to remove XE7 version of AndroidManifest.template.xml, created .dproj-file in XE10, - nothing helps!.

WTF?

Thanks!

1
In 10.1 Berlin (not 10.0 Seattle), you can receive a broadcasted Android Intent using IFMXApplicationEventService.SetApplicationEventHandler() and TMessageManager.SubscribeToMessage() to process TMessageReceivedNotification messages.Remy Lebeau
See Embarcadero's AndroidIntents examples.Remy Lebeau
BTW, there is no XE10! Get that out of your head. There is 10.0 Seattle, 10.1 Berlin, etc. Which one are you actually using?Remy Lebeau
I use the following component working also in 10.0: github.com/barisatalay/…Andre Ruebel
@RemyLebeau, you're right about XE10 ) I mean and use Delphi 10 Seattle. Will try TMessageReceivedNotification, but I doubt that it is.Alexey Shumkin

1 Answers