What is the difference between Local, Normal, Ordered and Sticky broadcasts?

Technology CommunityCategory: AndroidWhat is the difference between Local, Normal, Ordered and Sticky broadcasts?
VietMX Staff asked 3 years ago

Normal Broadcast

  • use sendBroadcast()
  • asynchronous broadcast
  • any receiver receives broadcast not any particular order

Ordered Broadcast

  • use sendOrderedBroadcast()
  • synchronous broadcast
  • receiver receives broadcast in priority base
  • we can also simply abort broadcast in this type

Local Broadcast

  • use only when broadcast is used only inside same process

Sticky Broadcast

  • normal broadcast intent is not available any more after this was send and processed by the system.
  • use sendStickyBroadcast(Intent)
  • the corresponding intent is sticky, meaning the intent you are sending stays around after the broadcast is complete.
  • because of this others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter)
  • apart from this same as sendBroadcast(Intent)