Android broadcast,

Source: Internet
Author: User

Android broadcast,

Normal broadcast:

1. Configure the broadcast receiver in AndroidManifest. xml:

<Cycler android: name = "com. example. toast. mybroadcasted Er">
<Intent-filter>
<Action android: name = "MyBroad"/>
</Intent-filter>
</Cycler>

2. A BroadcastReceiver object must be inherited.

3. Pass the message through the intent Method

4. Call the sendBroadcast (intent) method of context.

Ordered broadcast: Like conventional broadcast, ordered broadcast has a priority and requires multiple receivers. Messages delivered can be terminated at any location or added at any location, howeverPacket () transmission,

For example:

Bundle bundle = new Bundle ();
Bundle. putString ("mes2", "01 received ");
SetResultExtras (bundle );

The receiver must use Bundle bundle = getResultExtras (true) to receive messages in the package.

System broadcast:

Notification ):

1. Three main categories involved:

Notification. builder is used to set dynamic Notification attributes.

Icationicationmanager mainly displays notifications and cancels the display.

Attributes of Notification settings

2. send Notification

1) Call the getSystemService (icationication_service) method to obtain the NotificationManager service of the system.

2). Create a Notification object

3). Set Notification Properties

4). send Notification through icationicationmanager

5). Send notify to cancel

 

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.