Worker Thread Task completion callback not available for IntentService

138 views Asked by At

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 ?

1

There are 1 answers

0
David Wasser On

You can override onDestroy() to know when the IntentService is shutting down. However, if you need to know this then you probably don't want to use IntentService. Just use Service and create and manage your own background Threads. You can then manage the lifetime of the Service however you want. IntentService isn't always the right approach. It is just a rapper around Service that provides some very specific worker Thread management.