ANDROID – BROADCAST RECEIVERS PART 3

You can read Part 1 here and Part 2 here.

send broadcasts

Android supports three mechanisms to send a broadcast:

  • Normal – send with sendBroadcast(Intent) and sends to all the receivers
how to send broadcast intents., <span>ANDROID – BROADCAST RECEIVERS PART 3</span>, KandZ
  • Ordered – send with sendOrderedBroadcast(Intent, String). It delvers to one receiver at a time. The receiver can also cancel the broadcast so no other receiver receive the broadcast.
how to send broadcast intents., <span>ANDROID – BROADCAST RECEIVERS PART 3</span>, KandZ

with permission

how to send broadcast intents., <span>ANDROID – BROADCAST RECEIVERS PART 3</span>, KandZ
  • Local Broadcast – send with LocalBroadcastManager.sendBroadcast(Intent) and only to receivers that are in the same app as the sender.
how to send broadcast intents., <span>ANDROID – BROADCAST RECEIVERS PART 3</span>, KandZ

Security

  • Any application can send an intent to any registered receiver. It is good practice to use permission to control who can send/receive intents.
  • Any application can send intents to a receiver that is registered statically in the AndroidManifest.xml. If you do not want the receiver to accept intents outside the application then use the attribute android:exported=”false” The receiver will be exposed only to components from the same application.
  • sendBroadcast and sendOrderedBroadcast allow any other application to receive intents. Use setPackage() to restrict broadcasts to a single application.
  • Send only local broadcasts with LocalBroadcastManager. The broadcast scope is limited to the application. The other applications cannot receive or send broadcast intents. It also faster.

THE END!!!

93500cookie-checkANDROID – BROADCAST RECEIVERS PART 3ANDROID – BROADCAST RECEIVERS PART 3

Related posts

One Thought to “ANDROID – BROADCAST RECEIVERS PART 3

Comments are closed.