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