Calling bindService will start the service if it has not been started, so you dont have to call both methods.
On Mon, Sep 27, 2010 at 6:15 AM, Olivier Guilyardi <[email protected]> wrote: > Hi, > > IIUC, there should only be one instance of a given service, it is a singleton. > > However, my (audio engine) service gets instantiated multiple times, although > I > do nothing for it. > > When the service crashes (for example when I uninstall the app through adb), > it > gets scheduled for restart ("Scheduling restart of crashed service.. "). I > understand this is an effect of the service being sticky. > > After that, when my app starts, it calls startService() and bindService(), and > the service gets appropriately started and bound. But the service is then > reinstantiated and onCreate() is called repeatedly, as many times it was > scheduled for restart. > > Each instance then wait for clients to bind and register, but onBind() is only > called in the "main" service instance. The additional instances wait a bit for > client to bind, and since that doesn't happen, they call stopSelf(). > > But stopSelf() has absolutely no effect in these "dead" instances, onDestroy() > is never called. > > The "main" service instance does work as expected, and when it decides to call > stopSelf(), onDestroy() is indeed called. > > Worse, all these dead instances accumulate, they never gets destroyed. > Therefore, their only possible end is a crash (which happen every time I > launch/install through adb), and thus scheduled restart. > > So that in the end I get many of these dead instances, which are restarted > progressively once by minute approximately. > > What's this?? > > -- > Olivier > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

