My requirement is this: My app needs to register for certain broadcasts. If my Activity is “showing” when I receive the broadcast, then I update the UI; else, I show a Notification.
Commonsware has come up with an elegant solution for this; using ordered broadcasts. My problem is that I want to do all of this locally, i.e., within my process. Unfortunately, LocalBroadcastManager does not have a sendOrderedBroadcast() equivalent.
- Is this just an oversight in the
LocalBroadcastManager? - Or is it pointing to a best practice (something to the effect that sending ordered broadcast locally is a bad idea)? If so, why?
- Or is this plain unnecessary and can be achieved by alternate means?
I ended up implementing my own
LocalBroadcastManagerwith ordered broadcast capability. The project is shared at github.Although it serves my immediate purpose, it is still rough around the edges. It needs a few enhancements (for example, the
setResult*andgetResult*methods). Code contributions are welcome 🙂