I have a service that runs in the background. This is normal if the system kills this service in low memory conditions, however I do not want the service to be restarted by the system.
So, to do this, I return the START_NOT_STICKY flag from my onStartCommand as such:
public int onStartCommand(Intent intent, int flags, int startId) {
However, when I open a bunch of applications 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 restarts when it should not be. Why is this? According to the START_NOT_STICKY documentation, you should not allow restarting the service. Is there any other way to prevent the service from restarting? Or can I tell when my service was restarted?
thank
android service
Nick Feb 28 '12 at 23:10 2012-02-28 23:10
source share