【问题标题】:Service restarts when killing activity process杀死活动进程时服务重新启动
【发布时间】:2013-05-10 05:16:42
【问题描述】:

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

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

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

我想知道是否有办法在 Activity 进程被杀死时保持服务运行。

【问题讨论】:

  • 您找到解决方案了吗?
  • @Perry_ml 不幸的是没有。我已经放弃了这个项目。

标签: android android-service


【解决方案1】:
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.

但你可以做到,

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

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多