Reputation: 4698
I am uploading some multimedia from my application And using a START_STICKY in the service to keep my application alive. The problem is that When I remove my app from recent task the service is restarted, causing cancellation of my uploading!
I dont want my service to be restarted when the app is removed from the recent task And
keep the uploading going on And then inform back to my app. How to do.
Upvotes: 0
Views: 641
Reputation: 8106
Aslong as your Service is not in foreground and you app is not a systemapp you can't make sure that it will run forever until the uploading progress is finished.
"maybe" viber or wechat or whatever uses a service which contains return_sticky and more likely a "resume"-technique. This restarts the service, compare how many bytes has been transfered already and continue on the last position.
You will get a "look&feel" that its still running
Upvotes: 1
Reputation: 8106
Override onTaskRemoved in your Service if you want to verify if the task has been removed.
@Override
public void onTaskRemoved(Intent rootIntent) {
}
You will need to use a foreground service to make sure the service wont be killed.
Upvotes: 0