onStartCommand after service process is killed when started with START_STICKY

转载 2015年11月18日 16:26:12

http://stackoverflow.com/questions/3963135/onstartcommand-after-service-process-is-killed-when-started-with-start-sticky


When a process is killed and recreated, it goes through the entire lifecycle again (starting at onCreate). Depending on how it was killed and how you save data it may or may not be available to you.

As for getting the intent back, there's a flag for START_REDELIVER_INTENT that will redeliver the intent.

如果service被杀死了,onStartCommand()返回的是START_STICKY,则会重启service,走整个生命周期(重新执行onCreate)。

如果service被杀死了,onStartCommand()返回的是START_REDELIVER_INTENT,则会重启service,走整个生命周期(重新执行onCreate),并且会重新传递Intent。


可以在程序中,使用android.os.Process.killProcess(android.os.Process.myPid());来模拟杀死整个进程,这样子service也就被杀死了。

Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket

Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket ...
  • vicklin
  • vicklin
  • 2014年12月22日 15:56
  • 1124

Event Handler to trigger User process tasks when the associated Organization is updated

TriggerOrganizationUserProcesses.javaimport com.thortech.xl.client.events.tcTriggerUserProcesses; i...

when you start Windows 7: "The Windows Boot Configuration Data file is missing required information"

When you start Windows 7, you receive the following error message: File: \Boot\BCD Status: 0xc0000...

When START-OF-SELECTION is Not Required

STATEMENT NOT ACCESSIBLE 语句不能访问 语法错误

RAC ASM instances crash with ORA-29702 when multiple ASM instances start(ed) [ID 733262.1]

RAC ASM instances crash with ORA-29702 when multiple ASM instances start(ed) [ID 733262.1] ...

JasperException: is quoted with " which must be escaped when used within the value

今天做了个JSP的Web程序,在自己机器上测试能够正常运行。可是,当我部署到另外一台机器上的时候,JSP中的表达式就出现了问题 异常信息如下: org.apache.jasper.JasperEx...

Android Studio异常:Manifest merger failed with multip/Unable to start the daemon process

Manifest merger failed with multip/Unable to start the daemon process/app:transformClassesWithJarMer...

32.Your database instance is running with full workload after database creation. You have decided to

32.Your database instance is running with full workload after database creation. You have decided to...

Attribute value request.getParameter("name") is quoted with " which must be escaped when used

which must be escaped when used within the value 问题解决 访问JSP时,报错:Attribute value is quoted wit...
  • ly_rose
  • ly_rose
  • 2014年11月29日 19:22
  • 2057

android避免service被杀 博客分类: android 1.在service中重写下面的方法,这个方法有三个返回值, START_STICKY是service被kill掉后自动重写创建

android避免service被杀 博客分类:  android   1.在service中重写下面的方法,这个方法有三个返回值, START_STICKY是servic...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:onStartCommand after service process is killed when started with START_STICKY
举报原因:
原因补充:

(最多只允许输入30个字)