Android Service Killed Immediately After Start, Despite Calling Startforeground()
I'm having a problem with my IntentService. Every time I start my service, the onDestroy() method is called as soon as the service becomes idle. I set up my service to run in the
Solution 1:
You need to look into using a regular Service
instead of an IntentService
. IntentService
is designed to keep running while it has work to do. Once you've finished your onStartCommand
method, it tries to stop.
See the docs:
Clients send requests through startService(Intent) calls; the service is started as needed, handles each Intent in turn using a worker thread, and stops itself when it runs out of work.
(Emphasis mine)
Post a Comment for "Android Service Killed Immediately After Start, Despite Calling Startforeground()"