Android service doesn’t restart when I close app


I’m doing some tests with services. My code in local service is just:
function TDM.AndroidServiceStartCommand(const Sender: TObject;
const Intent: JIntent; Flags, StartId: Integer): Integer;
Result := TJService.JavaClass.START_STICKY;
my_log(‘Service started’);

But service doesn’t restart when I close the app. I know that a local service runs in the same process as the app so it is normal the service finish, but START_STICKY should start the service automatically but this is not happening. The service only starts automatically when I open the application again.
Is this a Delphi issue? In applications made in Java the service starts correctly.
I’m running on Android 10.

Comments are closed.