You really shouldn't use a ServiceConnection as a singleton, since it is associated with a context. Have a look at the LocalService sample code, and you can just have a simple callback registry on your service that each bounds client can use to get callbacks.
On Wed, May 19, 2010 at 2:18 PM, redneon <[email protected]> wrote: > I'm new to Android development and am working on a small test project. > I have a service, which communicates with an SQLite3 database, and two > activities. A main activity which fetches database information via the > service and displays it and a second activity which allows me to add > data to the database via the service. > > Currently, I have a singleton class which implements the > ServiceConnection interface and I'm binding this to the service in the > the main activity using the bindService function. Because it's a > singleton, I can then use this service connection in both the main > activity and second activity to work with the database and it all > seems to work quite well. > > However, I'm all the time aware that the service connection is bound > to the main activity and I'm wondering if this is the wrong/bad way to > do it? Would I be best off having two service connections, one in each > activity, and binding each to the service? > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. 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 [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

