I have a service that runs in the background. It is fine if the system kills this service on low memory conditions, however, I do not want the service to be restarted by the system.
So in order to do this I return the START_NOT_STICKY flag from my onStartCommand as such:
public int onStartCommand(Intent intent, int flags, int startId) {
// do stuff here
return START_NOT_STICKY;
}
However, when I open a bunch of applications on purpose to create low memory conditions I see this in the logs:
Process com.myapp (pid 3960) has died.
Scheduling restart of crashed service com.myapp/.MyService in 5000ms
Low Memory: No more background processes.
...
Start proc com.myapp for service com.myapp/.MyService: pid=4905 uid=10031 gids={3003, 1015}
So my process IS being restarted when it shouldnt be. Why is this? According to the documentation START_NOT_STICKY should not allow the service to be restarted. Is there any other way to prevent the restart of the service? Or can I tell when my service has been restarted?
Thanks