O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Long-Running Service Implementation

Now that the LightedGreenRoom implementation is finished, we are almost ready to present the long-running service abstraction. However, we have to take one more detour to explain the lifetime of a service and how it relates to the implementation of onStartCommand. This is the method that is ultimately responsible for starting the worker thread and the semantics of a service.

You know that the broadcast receiver invokes the service using a startService call and that this call will result in calling the onStartCommand method of the service. The lifetime of the service is controlled by what this method returns.

To understand what happens in this method, you need detailed background on the nature of local services. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required