Joke Collection Website - Blessing messages - Android SMS broadcasting

Android SMS broadcasting

Classification of registered broadcasting: static registration and dynamic registration.

Static registration: directly register in the manifest file, and receive the broadcast all the time from opening the application to destroying the application, which takes a long time, but the priority of receiving the broadcast is lower than that of dynamically registered broadcast.

Dynamic registration: dynamic registration and dynamic destruction, from onCreate to deregistration, during which the broadcast is received, with short and controllable broadcast receiving time and high priority. For example:

Send a broadcast:

Intent I = new Intent();

I。 set ACTION(“ACTION _ CLOSE“);

Send a broadcast (1);

Accept the broadcast:

onCreate(){

//Register the receiver of the broadcast.

intent filter filter = new intent filter();

filter . addaction(“ACTION _ CLOSE _ ACTIVITY“);

receiver = new inner receiver();

RegisterReceiver (receiver, filter);

}

Private class InnerReceiver extends BroadcastReceiver {

@ Overlay

Public void on Receive {

? //What //TODO needs to do when the current activity receives the broadcast.

}

}

}

//Log off the broadcast

@ Overlay

Protected void on destroy(){

super . on destroy();

UnregisterReceiver;

}

2. Reasons for introducing broadcasting:

A) Messaging between different applications is universal.

B) Publish the assignment, which requires multiple activities to respond.

Note: The above is for reference only. If you have any questions, please ask. Thank you.