9. Four major components-broadcast Receiver

Source: Internet
Author: User

Course objectives:

Measure the test taker's understanding about the android message mechanism.

Master two types of broadcast messages

Master broadcastreceiver's message receiving programming

Key and difficulties:

Sendorderedbroadcast ()

Assessment objectives:

What are the two Broadcast types sent in Android? And their differences?

What should I do when writing broadcastreciever?

 

 

I. What is the function of broadcast reveiver and why?

Used to receive system and custom messages.

Notify and determine the execution status in the system

1. system execution status: The system is started, the TF card is plugged in and out, the system is ready to shut down, the power is low, and the MSMQ.

2. Custom execution status: the message sending prompt update interface.

 

Ii. What messages does broadcast receiver receive?

Regular message (normal broadcasts), sent through context. sendbroadcast

Ordered messages (ordered broadcasts) are sent through context. sendorderedbroadcast

 

3. FAQ: What are the differences between the two types of messages?

 

4. How to Use

Inherits the broadcastreceiver class.

Reload the onreceive () method.

Configure <reciever> and <uses-Permission> In androidmanifest. xml.

 

5. How to enable the service when the system starts?

Android system in manifest. permission has such a definition of receive_boot_completed. When your program has this permission, you can receive a system broadcast after the system is started. The broadcast flag is action_boot_completed, therefore, we only need to define a broadcastreceiver to receive the broadcast and add a custom action.

 

6. FAQ: Thoughts on the life cycle of the host process received by broadcastreceiver

 

 

9. Four major components-broadcast Receiver

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.