Android Localbroadcastmanager improves Application security

Source: Internet
Author: User

  • 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.