Broadcast receiver for Android

Source: Internet
Author: User

Broadcast receiver is used to monitor the intent.

Android uses a lot of broadcast receiver, such as: Power on, call in, send messages, cell phone is too low

There are two ways of registering broadcast receiver.

1. Register in Code

  

2. Register in the manifest file

Receiver registered in this way is always active, even if the application shuts down

There is also a sticky broadcast, he is a variant of broadcast. This broadcast will save the value of the last broadcast, when a newly registered Boradcast receiver

You can get to the last value directly.

Typical application scenario: get battery changes.

If I were to recharge my phone now, the broadcast event had been sent out. Now I write a code to register the word receiver, if it is normal boradcast reveiver, because the broadcast has been sent out, we can not receive any information,

But with sticky broadcast, you can get the last message (the battery is now in the charging state)

Broadcast receiver for Android

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.