Joke Collection Website - Public benefit messages - When does Android use the radio?

When does Android use the radio?

You shouldn't say when to use the radio. Broadcasting is a design pattern. You can use it whenever you want or need it. You can even design a broadcast mode yourself.

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);

}

}

}

}