tags:

views:

52

answers:

1

Can one service be bound to n activities?

+4  A: 

Yes it can.

From the documentation at http://developer.android.com/intl/zh-TW/guide/topics/fundamentals.html#servlife

Clients establish a connection to the Service object and use that connection to call into the service. The connection is established by calling Context.bindService(), and is closed by calling Context.unbindService(). Multiple clients can bind to the same service.

and from http://developer.android.com/intl/zh-TW/reference/android/app/Service.html#ServiceLifecycle

A service can be both started and have connections bound to it. In such a case, the system will keep the service running as long as either it is started or there are one or more connections to it with the Context.BIND_AUTO_CREATE flag. Once neither of these situations hold, the service's onDestroy() method is called and the service is effectively terminated. All cleanup (stopping threads, unregistering receivers) should be complete upon returning from onDestroy()

So, a service can have multiple bindings.

rcabaco