My problem is that I don't know how/when to stop the service.
IntentService
automatically stops itself when onHandleIntent()
ends, if no more commands had been sent to it while onHandleIntent()
was running. Hence, you do not manually stop an IntentService
yourself.
When I call stopself() in onHandleIntent(Intent ..) all Intents which are waiting in the IntentService queue are removed.
Which is why you do not do that.
But I don't want to stop the service from an activity because I want to complete upload proccess even if my application is not running.
Then you let the IntentService
stop itself.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…