4

android:process我有一个活动,它通过我的服务属性在单独的过程中启动服务。

我的服务onStartCommand()功能返回START_STICkY.

我通过“最近的应用程序”按钮将我的活动进程删除,然后服务进程重新启动。

我想知道是否有办法在活动进程被终止时保持服务运行。

4

1 回答 1

0
I want to know if there is a way to keep the service running when the activity process is killed.

不,没有办法保持服务运行。因为,

Closed by the user via the Running Services screen in Settings.

Closed by the user via a task killer.

Closed by Android to free up memory in times of need.

保持服务运行是个坏主意。

但你可以这样做,

--> 您可以使用BROADCAST RECEIVER重新启动您的服务。(当来电、启动完成、收到短信等时,根据您的要求使用它)

于 2013-05-10T05:28:41.007 回答