I have a gone through couple of LocalBroadcastManager Android tutorials but could not find actual use of it and why to use it?
-
2Use it when you want to communicate internally from one part of your app to another. Service to activity for example. Activity to fragments, etc. – Ken Wolf Mar 11 '15 at 10:31
-
Thanks for your comment. Can you please post your answer in more details with sample links containing good resources to understand basic functionality? – VVB Mar 11 '15 at 10:42
1 Answers
It's exactly what the name implies. A Broadcast
. From one side of your app you broadcast a message that other parts of your app can be listening to.
"good resources to understand basic functionality?". The description above is all the functionality.
An example I can give you is the app I work on.
There's a photo upload on a Service
. At the end of the upload the server sends information about the photo and if the user is on the app main activity
we update the main activity with this extra information. So the service
sends a LocalBroadcast
with this information and the main activity
register/unregister to listen to it during onStart
/onStop
callbacks.
The same could be achieved by having the main activity
binding to the service
, implements an interface and register itself as a listener but the LocalBroadcast
is just much simpler to code.
A good alternative to LocalBrodcast
is to use a bus library like Otto from Square

- 39,391
- 16
- 102
- 144