As per developer guidelines, IntentService starts worker thread and destroys self. Next task is taken care by worker thread.
Worker thread do not notify into IntentService that task has been completed and is getting stopped.
Your code into onDestroy gets immediate invocation once service started and destroyed following start which is on Main Thread.
How to resolve issue when you do not get worker thread task completion callback into IntentService ?
You can override
onDestroy()
to know when theIntentService
is shutting down. However, if you need to know this then you probably don't want to useIntentService
. Just useService
and create and manage your own backgroundThread
s. You can then manage the lifetime of theService
however you want.IntentService
isn't always the right approach. It is just a rapper aroundService
that provides some very specific workerThread
management.