IIUC, there should be only one instance of this Android service, this is singleton.
However, my service receives multiple instances, although I do nothing for this.
If the service fails (for example, when uninstalling the application via adb), it receives the scheduled reboot ("Planning the restart of the emergency service .."). I understand that this is the effect of using sticky services.
After that, when my application starts, it calls startService () and bindService (), and the service gets the proper start and binding. But the service is then restantiated and onCreate () is called multiple times, how many times has it been scheduled for a reboot.
Each instance then waits for clients to contact and register, but onBind () is only called in the "main" instance of the service. Additional instances wait a bit for the client to bind, and since this does not happen, they call stopSelf ().
But stopSelf () has absolutely no effect in these "dead" cases, onDestroy () is never called.
The "main" instance of the service works as expected, and when it decides to call stopSelf (), onDestroy () is really called.
Worse, all these dead cases accumulate; they are never destroyed. Therefore, their only possible end is a crash (which happens every time I start / install via adb), and thus a scheduled restart.
So in the end, I get a lot of these dead cases that restart gradually about once per minute.
Does anyone know what is going on?
android
olivierg
source share