I got this code from somewhere, a book I think:
public class KITSMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// get the SMS message that was received
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
Log.d(LOGTAG, "DavyCrockettKingOfTheWildFrontier.onReceive");
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
String senderTel = "";
for (int i = 0; i < msgs.length; i++) {
// get the body of the message
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
// get the msg body
str += msgs[i].getMessageBody().toString();
str += "\n";
}
. . .
...but now as I look at the comments I'm a bit bamboozled. One line says: "get the body of the message" and then the next line says, "get the msg body". If this is really "the preferred method" for extracting the SMS body, why does it appear, according to the comments, to be done twice?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)