...

/

Broadcast Receivers

Broadcast Receivers

Learn about broadcast receivers in Android apps.

The Android OS can disseminate messages to apps and vice versa. Apps can also send messages to each other. These messages are broadcast when some already registered events occur. For instance, Android sends broadcast messages when the battery charging starts or the system boots up. Apps can broadcast custom messages, such as notifications of completed downloads, to notify other apps.

The job of Android broadcast receivers is to broadcast messages. They’re components of Android apps that listen to the events or intents across the OS. Let’s explore broadcast receivers.

Steps

The following diagram shows the steps to implement broadcast receivers.

Press + to interact
Steps to implement a broadcast receiver
Steps to implement a broadcast receiver

We explain these steps below.

Creating a broadcast receiver

The Android OS sends broadcasts automatically when a system event occurs. Android wraps the broadcast message in an Intent object whose action field describes the event that has happened. The Extras field of the intent can bundle additional information, such as the subject and the body of the email along with the ACTION_SEND. Each broadcast action has a constant field ...