- Official document explanation: Helper to register for and send broadcasts of Intents to local objects within your process. This is have a number of advantages over sending global broadcasts with
Context.sendbroadcast (android.content.Intent) :
- you know that the data is broadcasting won ' t leave your app, So don ' t need-worry about leaking private data.
- it is not possible for other applications to send these broadcasts to your app N ' t need to worry on having security holes they can exploit.
- it is more efficient than sending a global broadcast through the SYS Tem.
- 2. Broadcasts sent by other apps will not be sent to your app, so you don't have to worry about security attacks.
- 3. Local broadcast is more efficient than global broadcast
How to use: Very simple, the class is a singleton, Create
Final localbroadcastmanager localbroadcastmanager=localbroadcastmanager.getinstance (this) ;
Registered:
Intentfilter filter=New intentfilter (); Filter.addaction ("Duanqing.test.localbroadcast.fly"); Localbroadcastmanager.registerreceiver (New Mybroadcastreceiver (), filter);
Send code:
Intent intent=New Intent (); Intent.setaction ("duanqing.test.localbroadcast.fly"); Localbroadcastmanager.sendbroadcast (Intent);
Android Localbroadcastmanager improves Application security