1. Definition and Importance

1.15. Broadcast Receivers

4. Broadcast Receivers

Definition

A Broadcast Receiver is a component that listens for system-wide or application-wide broadcast messages. A Broadcast Receiver is a component that listens for system-wide broadcasts. These broadcasts can be sent by the system (e.g., when the battery is low, when a network connection is established) or by other apps.

Purpose: Broadcast Receivers allow apps to react to system events or events from other apps. For example, an app might listen for a broadcast that indicates that a new SMS message has arrived.

Key Characteristics

  • They enable communication between the system and applications.
  • Used to respond to events like battery level changes, network connectivity changes, or SMS reception.
  • Can be declared in the manifest or registered dynamically.

Types of Broadcasts

  1. System Broadcasts: Sent by the Android system (e.g., android.intent.action.BOOT_COMPLETED).
Custom Broadcasts: Sent by applications using sendBroadcast().