Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No call to onStartCommand() follows the restart of a crashed service in Android 2.3

I have a problem with Android service restart. I am building against API version 7 and running on a device with Android 2.3.3.

The problem is, that when my service is killed by the system and is later restarted, only the onCreate() of my service is called. code in onStartCommand() is not executed. If I start my application for the first time, the code in onStartCommand() is normally executed and all works fine, until system kills my service, then the service will not restart correctly.

Documentation says that onStartCommand() is always called when a service is restarted. In the case of service restart, the onStartCommand() should be called with null intent. This is not my case.

Any idea why this could happen?

like image 261
shelll Avatar asked Mar 22 '11 16:03

shelll


1 Answers

You might be seeing a bug in Gingerbread. There was a thread in the android-developers group about it: onStartCommand bug thread

See the post numbered 26 by Dianne Hackborn for details.

like image 191
Brian Cooley Avatar answered Sep 21 '22 14:09

Brian Cooley