I have a simple Android Activity with one button to start and stop a long 
running Android Service (which does some simple logging). As soon as I 
start the service, I close the app (Activity) and the service should then 
run in the background indefinitely.

But it doesn't. At random times, the Application object this Service 
belongs to is recreated by the OS and then my Service is as well. So it's 
not just that the Service is getting onStartCommand called, but first it 
gets onCreate called, creating a new Service. I don't know what happens to 
the old one, it just goes away - onDestroy is not called or anything.

I run the Service as START_STICKY, I am not using the main UI thread in any 
way, so there should be no issues there. I am Logging all activity from the 
Service, logging exceptions, etc. Nothing is out of the ordinary except 
that my Service is getting recreated over and over. I just can't understand 
what the problem is.

The Service is running fine, then boom, my Application gets an onCreate, my 
Service gets an onCreate and onStartCommand and the old Service, which was 
in the middle of logging goes, away without any notice or warning. The new 
Service starts logging. I end up with a bunch of disconnected logs where 
there should be just one.

-- 
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

Reply via email to