it is a tracking app of 24*7. Whenever it stops i use START_REDELIVER_INTENT to restart it, but it is not start every time. It shows below type response in Application manager. Please suggest.
Asked
Active
Viewed 553 times
5
-
Dear Teekam, It's not clear how you implemented, the problem should not occur normally. Please let me know some more info that may be helpful. Also you may explicitly perform grbge collection before the starting of the service, this may help. let me me know more info – FraZer Feb 27 '14 at 16:39
-
You have to add way more info in your question. We don't know even what you're doing. I recommend adding several `Log.d()` lines within your `Service` to see where it crashes and why and then will be able to help better. My *blind* guess is that you're running this as a **background** service instead of a **foreground** one, and that's why it's crashing. – nKn Mar 17 '14 at 13:24
2 Answers
3
I just discovered that if the service is killed on on 4.1.1, START_REDELIVER_INTENT can take even 20 minutes to restart the service. The restart always coincides with the next dalvikvm garbage collection. Until then the service is stuck on "Restarting" as shown in the question.
However START_STICKY restarts the service within seconds of being terminated.

Monstieur
- 7,992
- 10
- 51
- 77
1
What version of Android are you trying this on?
Android 4.4.x (API 19) has some issues with background services being killed and not restarted, regardless of flags. These bugs have been widely reported but there has been no official acknowledgement of them by anyone with AOSP.
Here are links to the relevant Android issue tracker reports: #63618 and #63793.

mike47
- 2,217
- 1
- 27
- 50
-
-
Then the bug I referenced is probably not the specific cause of your problem. Please add additional information to your question as other commenters have requested. Perhaps some sample code would help to start with. – mike47 Mar 19 '14 at 07:30
-
I have the same problem even on 4.1.1 with a foreground service. START_STICKY works fine but START_REDELIVER_INTENT doesn't. When the service is killed the notification icon disappears and the application manager says "Restarting" like above and "0 processes and 1 service". I have not called stopSelfResult yet. On 4.4.2 the same thing happens except the notification icon remains. – Monstieur Sep 09 '14 at 06:56