user3684678
user3684678

Reputation: 561

When will service stop if i don't call stopService() or stopSelf() methods

If you start a service by calling startService() then you have to call stopService() or stopSelf() to stop the service. If you want to stop a service after doing some work, you might want to use IntentService instead.`

If I am NOT using IntentService then when will the service stop if I don't call the stopService() or stopSelf() methods?

Upvotes: 2

Views: 1099

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006554

If I am NOT using IntentService then when will service stop if I don't call stopService() or stopSelf() methods?

If your service was started via startService(), and you do not call stopService() or stopSelf(), your service will be considered "running" until your process is terminated. You may or may not get called with onDestroy() as part of this, depending on how urgent the need is for your process' system RAM.

If, from onStartCommand(), you returned START_STICKY or START_REDELIVER_INTENT, your process and service is supposed to be restarted automatically at some time in the not-too-distant future, when RAM needs permit it.

Upvotes: 2

Related Questions