I'm using Delphi 10.3 for developing android application and I have implemented Service to retrieve the data from Server. The thread was running properly but it closes when the app is closed. I have used the following code to run the service:
DMService.StartCommand();
begin
AddLog; //Log
SampleThread := TThread.Create;
Result := TJService.JavaClass.START_REDELIVER_INTENT;
end;
The same code worked fine in Delphi 10.1 (without mentioning the Android 26 as target version).
Also I have tried using TTask but still the problem does not resolves.
Also I have tried Result := TJService.JavaClass.START_STICKY;
, but still the service closes.
And after several analysis, I have analyzed after closing the host application the service, the Service starts again and the thread/Task initiated and the service was destroyed.
Should I need to enable any special permission or while creating should I need to add more code. Currently, I'm using the following code for initiating the service from the host application:
FLocalServiceConnection := TLocalServiceConnection.Create;
FLocalServiceConnection.StartService('SCommuteSupervisorNotificationService');
Please help me to resolve this issue to run the service after the host app closes.