0

当我强行杀死一个应用程序时遇到了这个问题。这个应用程序创建的服务也被杀死了。但是,我想在应用程序被强行关闭时保持服务。我该怎么办?

4

1 回答 1

1

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).

于 2013-09-21T13:43:51.730 回答