I searched android from the Internet.
Broadcast Mechanism, used to implement communication between different activities, or message listening, mainly to implement an activity
The response of another activity in a certain state is as follows:
Broadcasttest
Mybroadcastreceiver;
....
// Register the message
Mybroadcastreceiver =
New broadcasttest ();
Intentfilter filter =
New intentfilter ();
Filter. addaction ("namefound ");
Registerreceiver (mybroadcastreceiver, filter );
// Internal class, after receiving the message implementation
Publicclass broadcasttest
Extends broadcastreceiver {
@ Override
Publicvoid onreceive (context arg0, intent arg1 ){
//
Todo auto-generated method stub
Getdata ();
}}
------------------------------------------------------------------------------
// Message broadcast
Intent intent = new intent ("namefound ");
Sendbroadcast (intent );
Note:
1. Filter. addaction ("namefound"); and intent =
New intent ("namefound ");
The parameters are consistent;
2. A message broadcast can be sent anywhere. However, if the received message is not registered, it cannot be received.
3. This is the simplest way to use, complex and not tested.