bound service is the service that is allowed to be bound by the application component, and the binding can be done by calling Bindservice ()
Used to create a long-standing connection (and generally no longer allows the component to start the service by calling StartService (). When an activity or other component in the application needs to interact with the , or the application's to other applications,
you should create a bound service and complete it through interprocess communication (IPC). To create a bound service, you must implement the Onbind () callback method and return a IBinder object that defines the interface that communicates with the service. Other application components can then call Bindservice () to get the interface
and invoke the methods in the service. The service survives only when it is working for the bound application component, so as long as no component is bound to the service, the
system automatically destroys the service (you do not need to terminate a bound service by Onstartcommand () as in the started service). To create a bound service, you must first define the interface , which indicates How the client communicates with the service .
The The interface must be an implementation of an IBinder object , and your service must return this object in the Onbind ()
callback method. Once the client receives the IBinder, it can interact with the service through this interface. The same service can be bound by more than one client. When the client finishes the interaction, Unbindservice () is called to unbind.
Once the client and service bindings are not present, the service is destroyed. There are many ways to implement bound services, and the process of implementing them is more complex than started types of services,
so bound services will be discussed in a separate bound service document.
Android four component value Service (3) binding services