• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

自动重启被杀死的服务?

用户头像
it1352
帮助1

问题说明

服务被杀后,如何自动重启?

When a service has been killed, how to restart it automatically?

有时甚至不调用onDestroy()

正确答案

#1

我继承了一个 IntentService,所以我必须要温柔.当我覆盖 onStartCommand() 但是

I inherited an IntentService, so I had to be gentle. It worked for me when I overrode onStartCommand() but

public int onStartCommand(Intent intent, int flags, int startId) {
   super.onStartCommand(intent, flags, startId);
   return START_STICKY;
}

也就是说,让父母做它应该做的事情并返回 START_STICKY.

That is, let the parent do what it should and return START_STICKY.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfkhba
系列文章
更多 icon
同类精品
更多 icon
继续加载