1

I don't have an idea about LocalBroadcastManager in the android. Links and blogs are highly appreciable.

Nikhil Katekhaye
  • 2,344
  • 1
  • 18
  • 19
  • local means not remote, remote in this case means cross process (so it would be work only in the same application instance) – Selvin Mar 14 '16 at 13:22
  • @Selvin what is differnce between LocalBroadcastManager and Broadcast Manager – Nikhil Katekhaye Mar 14 '16 at 13:26
  • You will find the best answer inside the api. LocalebroadcastManager: http://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html and BoradcastReceiver http://developer.android.com/reference/android/content/BroadcastReceiver.html – Opiatefuchs Mar 14 '16 at 13:31
  • they have only common interface, LocalBroadcastManager is a simple publish–subscribe pattern implementation which doesn't involve OS ... the "normal" if for rpc (that's why "normal" is "more expensive") – Selvin Mar 14 '16 at 13:37

2 Answers2

4

LocalBroadcastManager :-

LocalBroadcast receiver used for inter-process communication which provides application security has it doesn’t allow other process to communicate. Also these broadcast not accessible outside the application so it also provide system security.

You don’t need to register in menifest has it is in local in app it is efficient.

Application gets crash if you are passing intent filter null LocalBroadcastManager.getInstance(context).register(broadcast,null);

Register broadcast :- LocalBroadcastManager.getInstance(context).register(broadcast, new intent filter);

UnRegister broadcast :- LocalBroadcastManager.getInstance(context).unregister(broadcast);

Send Broadcast :- LocalBrodcastManager.getInstance(context).sendBroadcast(new Intent())

you can refer below given link

how to use LocalBroadcastManager?

so many people doesn't know about How to measure whether broadcast is send successfully or not.

sendBroadcast(receiver) :- which returns true or false. true - broadcast send successfully to register receiver. false - broadcast not register.

Community
  • 1
  • 1
Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147
2

Local broadcast manager is a events consumer/raiser system that lives only into the app that raise event. You can subscribe with:

LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, intentFilter);

and can raise event:

LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(new Intent("intent action")
alrama
  • 618
  • 11
  • 17