Service binding relationship

Is it possible to bind one service to n actions?

+2


a source to share


1 answer


Yes it is possible.

From the documentation at https://developer.android.com/guide/components/fundamentals.html :

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



and https://developer.android.com/reference/android/app/Service.html#ServiceLifecycle :

A service can be started and associated with it. In this case, the system will keep the service running as long as it is running or there are one or more connections to it using the Context.BIND_AUTO_CREATE flag. When none of these situations occur, the onDestroy () method of the service is called and the service is effectively terminated. All cleanup (stopping threads, unregistered sinks) should be completed after onDestroy () returns

Thus, a service can have multiple bindings.

+5


a source







All Articles