So far in this book, everything you have learned is related to activities. It is now time to present another Android component, the service. A service has no user interface and runs in the background. It is suitable for long-running operations. This chapter explains how to create a service and provides an example.
As already mentioned, a service is a component that perform a long running operation in the background. A service will continue to run even after the application that started it has been stopped. A service runs on the same process as the application in which the service is declared and in the application’s main thread. As such, if a service takes a long time to complete, it should run on a separate ...