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!
Intent
usingIFMXApplicationEventService.SetApplicationEventHandler()
andTMessageManager.SubscribeToMessage()
to processTMessageReceivedNotification
messages. – Remy Lebeau