2013-05-10 75 views
4

我有一项活动,通过我的服务的android:process属性在单独进程中启动服务。当查杀活动进程时服务重新启动

我的服务onStartCommand()函数返回START_STICkY

我通过最近的应用程序按钮刷掉我的活动进程,服务进程重新启动。

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

+0

您是否找到解决方案了? – 2014-01-16 13:52:19

+0

@Perry_ml不幸的是。我已经放弃了这个项目。 – 2014-01-16 17:29:55

回答

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. 

Keep the service running is BAD idea.

但是你可以做,

- >您可以重新启动使用广播接收机您服务(当接收的来电,启动完成,短信..使用这取决于您的要求)