microtronx 38 Posted January 21, 2020 (edited) Hi Folks, i'm new to Android Services world but have successful created my first app with a background-service (used demo of Kastrifree / CrossPlatformLocation) as base. It works good, but as soon i add a tfdconnection for a local sqlite table or a TDSRestConnection for connecting to a remote-server in the service-module it does not start. My question is: What are the limits of a android-service-module created with Delphi Rio? What is blocking the service from starting if we add one of those components? Edited January 21, 2020 by microtronx Share this post Link to post
Dave Nottage 557 Posted January 22, 2020 I'm able to use FireDAC with SQLite OK in the demo you refer to. Can you provide a test project for the TDSRestConnection issue? Share this post Link to post
microtronx 38 Posted January 22, 2020 (edited) If i open the demo, select the service as active project and add a new clientmodule to a datasnap-server, save it and change the code in locationchangehandler to this: procedure TServiceModule.LocationChangeHandler(Sender: TObject; const ALocation: TLocationCoord2D; const ASource: TLocationSource); var LStatus: Integer; begin // This is where to use the location data to update a server, or to a database when not connected to the internet and the data is to be sent later LStatus := 0; // Service in foreground means app is inactive if IsForeground then LStatus := 1; if FBackgroundMonitor.IsDozed then LStatus := 2; // FUpdater.SendLocation(ALocation, LStatus); try if locationClientModule.ServerMethodsClient.savelocation('hardwareidxx', aLocation.Latitude, aLocation.Longitude, lStatus, now())=true then begin toslog.d('savelocation REST OK'); end; except on e:Exception do begin toslog.d('savelocation REST Error:'+e.message); end; end; end; plus add the locationclientmodule's unit to implementation/uses the module does not start any more, this is from logcat: 01-22 12:40:55.046 1491 1510 W ActivityManager: Timeout executing service: ServiceRecord{8ba5020 u0 org.xxxx.xxxx/com.embarcadero.services.xxxxLocationService} 01-22 12:40:57.623 1491 1510 E ActivityManager: Reason: executing service org.xxxx.xxxx/com.embarcadero.services.xxxxLocationService I have also tried to add only a tfdConnection and a tfdQuery onto service-module and same problem, the service can't be started. the device i'm testing this is a Huawei P30-Lite with Android 9 on it. Possible that the problem is connected with this? Edited January 22, 2020 by microtronx Share this post Link to post
microtronx 38 Posted January 22, 2020 5 hours ago, Dave Nottage said: I'm able to use FireDAC with SQLite OK in the demo you refer to. Can you provide a test project for the TDSRestConnection issue? Now i can note, that only adding the servermethodsclient's unit to implementation use clause is enough so the service is not starting any more. You don't have to use anything in your source. Share this post Link to post