Learn about Android Broadcasts

Learn about Android Broadcasts

Below is a summary of core knowledge points for the Android broadcast system:

1. Basic Concepts of the Broadcast System

  • Real-world analogy: Similar to loudspeakers, radios and televisions, meaning “sent from one location and received by multiple locations”.
  • Android mechanism: Provides a flexible broadcast messaging system. Each app may register for broadcasts it is interested in to receive only specific content.
  • Broadcast sources: May come from the system (e.g. device boot, battery level changes) or from other applications.
  • Sending and receiving: Broadcasts are normally sent via Intent; broadcast reception relies on BroadcastReceiver. Android offers a complete API set to freely send and receive broadcasts.

2. Types and Comparison of Broadcasts

Android broadcasts are mainly divided into Normal Broadcasts and Ordered Broadcasts. Their core differences are listed below:

Comparison ItemNormal BroadcastOrdered Broadcast
Execution ModeFully asynchronousSynchronous sequential execution
Reception TimingAll receivers receive simultaneously once dispatchedOnly one receiver receives at a time; the next runs only after processing completes
Order of DeliveryNo defined orderOrdered delivery; receivers with higher priority get events first
Abort MechanismCannot be aborted; all receivers will receive the broadcastEarlier receivers may abort the broadcast, blocking subsequent receivers
PerformanceHigh efficiencyRelatively slower (depends on delivery chain)

3. Workflow Diagram Explanation

  • Normal Broadcast
    Broadcast sent → Distributed concurrently to BroadcastReceiver 1, BroadcastReceiver 2, BroadcastReceiver 3 (radial delivery, no interception).
  • Ordered Broadcast
    Broadcast sent → BroadcastReceiver 1 (may abort) → BroadcastReceiver 2 (may abort) → BroadcastReceiver 3 (linear delivery).

Leave a Reply

Your email address will not be published. Required fields are marked *