Describe Android service life cycle along with diagram
● A service is an application component which runs without direst interaction with
the user in the background.
● Services are used for repetitive and potentially long running operations, i.e.,
Internet downloads, checking for new data, data processing, updating content
providers and the like.
● Service can either be started or bound we just need to call either startService() or
bindService() from any of our android components. Based on how our service
was started it will either be “started” or “bound”
SERVICE LIFECYCLE
. Started
a. A service is started when an application component, such as an activity,
starts it by calling startService().
b. Now the service can run in the background indefinitely, even if the
component that started it is destroyed.
2. Bound
a. A service is bound when an application component binds to it by calling
bindService().
b. A bound service offers a client-server interface that allows components to
interact with the service, send requests, get results, and even do so across
processes with InterProcess Communication (IPC).
c. Like any other components service also has callback methods. These will
be invoked while the service is running to inform the application of its
state. Implementing these in our custom service would help you in
performing the right operation in the right state.
•
d. There is always only a single instance of service running in the app. If you
are calling startService() for a single service multiple times in our
0 Comments