Joke Collection Website - Blessing messages - Android SMS broadcasting
Android SMS broadcasting
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.
- Related articles
- The interviewer asked if the account you operated was realized.
- How does Apple's mobile phone connect to the computer?
- The Year of the Ox sends greetings to teachers.
- Physical examination reminder SMS template
- Break up after six years of extramarital affairs. I texted him to pay him back, but he didn't. What happened?
- How to pick up Yangcheng Lake hairy crabs?
- Precautions for the use of washing machines What are the precautions for the use of washing machines?
- Is it true that 10086 points can be exchanged for cash?
- How did the king close do not disturb mode?
- How to write a good information briefing