Reputation: 561
If you start a service by calling
startService()
then you have to callstopService()
orstopSelf()
to stop the service. If you want to stop a service after doing some work, you might want to useIntentService
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
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