Android dynamic register broadcast Receiver

Source: Internet
Author: User

In essence, the broadcast mechanism of the Android system is a message subscription/publishing mechanism. Therefore, the first step to use this message-driven model is to subscribe to messages. for Android applications, subscribing to a message is actually registering a broadcast receiver.
Two registration methods are available: static registration and dynamic registration. In the Broadcast Mechanism of Android, the priority of Dynamic Registration is higher than that of static registration. Therefore, when necessary, we need to dynamically register the broadcast receiver.

Let's review static registration. The so-called registration is to register the broadcast receiver in Manifest. xml.
[Java]
<Cycler android: name = "">
<Intent-filter android: priority = "2147483647">
<Action android: name = "android. provider. Telephony. SMS_RECEIVED">
</Action>
</Intent-filter>
</Cycler>
Then create a class that inherits BroadcastReceiver. Specifically, the priority in the intent-filter label sets the priority of the broadcast receiver. Many data on the Internet shows that the priority value is set to 1000 ~ -2147483647, is the largest, but in fact, when the priority value is the maximum integer value, it is the highest priority, that is,; of course, the "highest" is limited to static registration.
Understanding

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.