Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping alive Intent Service after application is killed

Tags:

I have intent service in my app. This service has some job to do - uploading some files. It runs only when there is something to do.

Service won't upload when some conditions are met, for example no Internet connection. For that reason it registers itself to on broadcast receiver to receive message about Internet connection changes.

The problem is that service is killed with app even if it is doing something, for example:

  1. App is sending intent to service
  2. Service started uploading something, everything fine
  3. X% uploaded, app is killed, service is killed
  4. Internet connection changed - service is woken up.

If service is woken up after app is killed, why is it killed with the app? Is there any way to prevent killing service when app is killed?

I'm killing app manually. I know android could kill my service anytime and I don't want to prevent it. I just want to have this service running after user closed or killed app.