Monday, March 5, 2012

Re: [android-developers] Crashed service restarted by system doesn't call onStart

So what is the right solution. Start service from onCreate?

On Wednesday, April 1, 2009 2:38:15 AM UTC+7, Dianne Hackborn wrote:
That is working as intended.  onStart() is called each time someone calls startService(); if nobody has called startService() since your last onStart(), then onStart() will not be called again.  The Service class does not have the same lifecycle as Activity; it is unfortunate we used "start" for the method here as well, because it is not the same as activity.

On Tue, Mar 31, 2009 at 12:31 PM, Charles Harley <charles.harley@googlemail.com> wrote:

I have noticed that if my background service crashes the system will
automatically restart the service after 5 seconds. This is great, but
I have noticed that only the onCreate method gets called and not the
onStart method. Does this mean the service is properly restarted or do
I need to do something special in the onCreate method to make sure it
is?

I did have my initialisation logic in the onCreate method and my
starting service logic in the onStart method but it looks like it will
all have to be in the onCreate method.

Many thanks,

Charles




--
Dianne Hackborn
Android framework engineer
hackbod@android.com

Note: please don't send private questions to me, as I don't have time to provide private support.  All such questions should be posted on public forums, where I and others can see and answer them.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment