Android Review--broadcast

Source: Internet
Author: User

There are two ways of broadcasting , a static broadcast and a dynamic broadcast.

Static broadcast---static broadcast receivers are registered inside the configuration file.

Dynamic broadcast receivers are registered in the code.

Sending of broadcasts:

Context.sendbroadcast ();

Context.sendorderedbroadcast ();

Context.sendstickybrodcast ();

A broadcast can be received by multiple broadcast receivers.

Broadcast receivers can only accept broadcasts and respond to broadcast notifications.

The broadcast recipient does not have a user interface, but can receive and initiate an activity.

Time-consuming operations are not possible in the broadcast, and time-consuming operations are time-consuming to service and activity by initiating service and activity.

Broadcastreceiver Security Issues

http://blog.csdn.net/yuanzeyao/article/details/38948863

Subscription to broadcast:

1. Register the broadcast receiver in the configuration file:

<receiver android:name= ". Comm. Connectivitychangebroadcastreceiver ">            <intent-filter>                <action android:name=" Android.net.conn.CONNECTIVITY_CHANGE "/>            </intent-filter></receiver>

2. Register the broadcast recipient in the code:

   

Intentfilter filter = new Intentfilter ();

Filter.addaction (intent.action_screen_on);

Filter.addaction (Intent.action_screen_off);

Filter.addaction (Intent.action_time_tick);

Registerreceiver (new Dynamicbroadcastreceiver (), filter);

Android Review--broadcast

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.