Chapter    16

Broadcast Receivers and Long-Running Services

A broadcast receiver is another component in an Android process, along with activities, content providers, and services. A broadcast receiver is a component that can respond to a broadcast message sent by a client. This message is modeled as an intent. Further, a broadcast message (intent) can be responded to by more than one receiver.

A client component such as an activity or a service uses the sendBroadcast(intent) method, available on the Context class, to send a broadcast. Receiving components of the broadcast intent will need to inherit from a BroadcastReceiver class available in the Android SDK. These broadcast receivers need to be registered in the manifest file through a receiver ...

Get Pro Android 5, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.