JackieWillen
JackieWillen

Reputation: 739

how to keep service on when app is closed forcibly?

I came across this problem when i killed an application forcibly.The service which is created by this application was also killed.But,i want to keep the service on when the application is closed forcibly.What should i do??

Upvotes: 0

Views: 67

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006664

If the user goes into Settings and stops your service, or uses Force Stop, there is nothing you can do. In particular, if the user taps on Force Stop for your app, your app will never run again, unless the user manually runs one of your components (e.g., taps on a launcher icon).

That is because "keep the service on when the application is closed" is frequently an anti-pattern in Android. Your service should only be running when the user perceives that it is adding value. Anything else is user-hostile, as it wastes RAM (and possibly CPU/battery, depending upon the service's implementation).

Upvotes: 1

Related Questions