BroadcastReceiver Tutorial Part 5 – ORDERED BROADCASTS – Android Studio Tutorial
In part 5 of the BroadcastReceiver tutorial, we will learn how to send and receive ordered broadcasts. Ordered broadcasts are sent to each registered BroadcastReceiver sequentially, and we can control the order in which the receivers are triggered by setting a priority on their intent filters. For statically registered receivers we use the android:priority attribute on the intent-filter tag, and for dynamically registered receivers we use the setPriority method on the IntentFilter object. BroadcastReceivers with higher priority will receive the broadcast before receivers with lower priority.
Together with the broadcast we can send a resultCode integer, a resultData String and a resultExtras Bundle. Each receiver can receive this data, make changes to it, forward it to the next receiver, or completely cancel the broadcast by calling abortBroadcast.
In the sendOrderedBroadcast method we can also specify a resultReceiver, which will be triggered at the very end of the broadcast.
Watch the whole playlist:
Example code for this part:
https://gist.github.com/codinginflow/5104c2c0514dad15eb64dad62988db07
____________________
💻 Find the BEST programming tutorials on TutHub:
https://tuthub.io
⭐ Get my MVVM Caching Course now:
https://codinginflow.com/caching
❗ Subscribe to the channel:
https://www.youtube.com/c/codinginflo…
📨 Subscribe to the Coding in Flow newsletter:
https://codinginflow.com/newsletter
❓ Join our free developer community:
https://discord.gg/TSnMvmc
📣 Follow Coding in Flow on other sites:
Facebook: https://www.facebook.com/codinginflow
Instagram: https://www.instagram.com/codinginflow
TikTok: https://www.tiktok.com/@codinginflow
Twitter: https://twitter.com/codinginflow
Github: https://github.com/codinginflow
💰 Business requests, sponsoring, etc.: info@codinginflow.com
Views :17035
android studio