I'm doing an Android service. It includes Motion Sensor, Location Sensor and the Telephony framework. After put it all together the application is crashing with Segmentation fault (11) that doesn't helps nothing. Following the crash debug finish here:

I'm doing an Android service. It includes Motion Sensor, Location Sensor and the Telephony framework. After put it all together the application is crashing with Segmentation fault (11) that doesn't helps nothing. Following the crash debug finish here:
procedure BindAppGlueEvents()
AndroidAppGlue := PANativeActivity(System.DelphiActivity)^.instance;

I tried do comment some lines, now the app should only call a notification and exit, but also fails. I waste a lot of hours yesterday trying to make it run again.
Running Delphi Tokyo with Java 8.
Thanks for any help

Comments

  1. This blog post looked relevant, seems the DelphiActivity is not available in services: danielespinetti.it - Using LocationSensor on Android Service in Delphi Seattle

    ReplyDelete
  2. Very good!!! Indeed that's the point, I am very help for this.

    ReplyDelete
  3. Asbjørn Heid Well, I began to start patch and the unit System.Android.Sensors that comes with Tokyo is very different. Seems that some kind of patch was tried there, exemple the line 1600 is now a whole new thing and line 1630 with Tokyo also already try do handle with this Sensor when there's no Activity evolved:
    if System.DelphiActivity <> nil then
    TAndroidHelper.Activity.runOnUiThread(ARunnable)
    else
    begin
    Handler := TJHandler.JavaClass.init;
    Handler.post(ARunnable);
    end;
    So I will first remove the MotionSensor and try only the Location.

    ReplyDelete
  4. Magno Lima Ah bummer. Never tried Delphi on Android, so can't help much further, sorry.

    ReplyDelete
  5. As you've discovered, at present you cannot use anything in an Android service app that relies on FMX units that use FMX.Types, which is pretty much all FMX.* units.
    quality.embarcadero.com - Log in - Embarcadero Technologies

    ReplyDelete
  6. Incidentally, I went through the same process with a couple of others not long ago (when we were attempting to make notifications work in a service), and abandoned the idea because it would have meant rewriting code in FMX.jar. The end result was to implement Firebase Cloud Messaging. There is a lot of code wound up in FMX that prevents it being used in a service; Log.d and TTimer are good examples. There are alternative ways of doing the same thing, but they should have been done right in the first place.

    ReplyDelete
  7. Even TTimer uses FMX? oh boy...

    ReplyDelete

Post a Comment