[android-developers] Re: Why does Android restart killed service?
The service is on some type of thread which you have not killed. As far as I remember you have to use a cancel() service commnand in the java code. They can be hard to stop if you don't. On Jul 27, 12:58 pm, m.andrew andreymandyc...@gmail.com wrote: Hi! I have an application with an activity and a service. The service is started by startService() and the activity is bound to it. The overridden onStartCommand() method returns START_NOT_STICKY. So I suppose that service will not be recreated if it's killed. But it will. I kill the application process by the command: adb shell kill pid. After killing the process the log shows that new process of my application is started again and the service is recreated. So my question is: Why does Android restart this service (the killed process)? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Why does Android restart killed service?
When an application process is killed all threads of this process are also killed. If killed application doesn't have a service a new process of this application wont start. But if killed application has a service a new process will start and service will be recreated. Does returned value of onStartCommand() influence on this situation? On 27 июл, 16:39, Droid rod...@gmail.com wrote: The service is on some type of thread which you have not killed. As far as I remember you have to use a cancel() service commnand in the java code. They can be hard to stop if you don't. On Jul 27, 12:58 pm, m.andrew andreymandyc...@gmail.com wrote: Hi! I have an application with an activity and a service. The service is started by startService() and the activity is bound to it. The overridden onStartCommand() method returns START_NOT_STICKY. So I suppose that service will not be recreated if it's killed. But it will. I kill the application process by the command: adb shell kill pid. After killing the process the log shows that new process of my application is started again and the service is recreated. So my question is: Why does Android restart this service (the killed process)? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Why does Android restart killed service?
As far as I remember I had to cancel the service specifically. Killing the App's pid is not sufficient. Even a timer thread can bring the App back. I do not know how to do that from adb. From Java code its easy as you know (service cancel()). Sorry if I am no help to you. I just remember this problem myself a month or two ago. On Jul 27, 1:57 pm, m.andrew andreymandyc...@gmail.com wrote: When an application process is killed all threads of this process are also killed. If killed application doesn't have a service a new process of this application wont start. But if killed application has a service a new process will start and service will be recreated. Does returned value of onStartCommand() influence on this situation? On 27 июл, 16:39, Droid rod...@gmail.com wrote: The service is on some type of thread which you have not killed. As far as I remember you have to use a cancel() service commnand in the java code. They can be hard to stop if you don't. On Jul 27, 12:58 pm, m.andrew andreymandyc...@gmail.com wrote: Hi! I have an application with an activity and a service. The service is started by startService() and the activity is bound to it. The overridden onStartCommand() method returns START_NOT_STICKY. So I suppose that service will not be recreated if it's killed. But it will. I kill the application process by the command: adb shell kill pid. After killing the process the log shows that new process of my application is started again and the service is recreated. So my question is: Why does Android restart this service (the killed process)? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Why does Android restart killed service?
Thanks for the replies, Yes, I know how to stop a service from source code. But the idea of START_NOT_STICKY flag is not clear for me in this case. Because the documentation says: START_NOT_STICKY - If the system kills the service after onStartCommand() returns, do not recreate the service, unless there are pending intents to deliver. This is the safest option to avoid running your service when not necessary and when your application can simply restart any unfinished jobs. On 27 июл, 18:51, Droid rod...@gmail.com wrote: As far as I remember I had to cancel the service specifically. Killing the App's pid is not sufficient. Even a timer thread can bring the App back. I do not know how to do that from adb. From Java code its easy as you know (service cancel()). Sorry if I am no help to you. I just remember this problem myself a month or two ago. On Jul 27, 1:57 pm, m.andrew andreymandyc...@gmail.com wrote: When an application process is killed all threads of this process are also killed. If killed application doesn't have a service a new process of this application wont start. But if killed application has a service a new process will start and service will be recreated. Does returned value of onStartCommand() influence on this situation? On 27 июл, 16:39, Droid rod...@gmail.com wrote: The service is on some type of thread which you have not killed. As far as I remember you have to use a cancel() service commnand in the java code. They can be hard to stop if you don't. On Jul 27, 12:58 pm, m.andrew andreymandyc...@gmail.com wrote: Hi! I have an application with an activity and a service. The service is started by startService() and the activity is bound to it. The overridden onStartCommand() method returns START_NOT_STICKY. So I suppose that service will not be recreated if it's killed. But it will. I kill the application process by the command: adb shell kill pid. After killing the process the log shows that new process of my application is started again and the service is recreated. So my question is: Why does Android restart this service (the killed process)? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en