what is pdus in bundle.get("pdus")?

Put your problem here if it does not fit any of the other categories.

what is pdus in bundle.get("pdus")?

Postby jprogyog » Thu Dec 04, 2008 3:04 pm

what is pdus in bundle.get("pdus")?

private SmsMessage[]
getMessagesFromIntent(Intent intent)
{
SmsMessage retMsgs[] = null;
Bundle bdl = intent.getExtras();
try{
Object pdus[] = (Object [])bdl.get("pdus");
retMsgs = new SmsMessage[pdus.length];
for(int n=0; n < pdus.length; n++)
{
byte[] byteData = (byte[])pdus[n];
retMsgs[n] =
SmsMessage.createFromPdu(byteData);
}
}
catch(Exception e)
{
Log.e("GetMessages", "fail", e);
}
return retMsgs;
}
jprogyog
Freshman
Freshman
 
Posts: 7
Joined: Thu Dec 04, 2008 8:26 am

Top

Postby kenjkelly » Thu Dec 04, 2008 10:36 pm

A PDU is a "protocol discription unit", which is the industry format for an SMS message. because SMSMessage reads/writes them you shouldn't need to disect them. A large message might be broken into many, which is why it is an array of objects.
kenjkelly
kenjkelly
Freshman
Freshman
 
Posts: 7
Joined: Mon Oct 06, 2008 3:30 am

Postby jprogyog » Fri Dec 05, 2008 6:39 am

Thanks kenjkelly.
but will u plz tell me what other keys i can pass to this method.
jprogyog
Freshman
Freshman
 
Posts: 7
Joined: Thu Dec 04, 2008 8:26 am

Postby MrSnowflake » Fri Dec 05, 2008 1:48 pm

You can use Set<String> Bundle.keySet() to see all the keys in the bundle!
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby jprogyog » Fri Dec 05, 2008 2:02 pm

Thanx 2 all for help.
jprogyog
Freshman
Freshman
 
Posts: 7
Joined: Thu Dec 04, 2008 8:26 am

Postby kenjkelly » Fri Dec 05, 2008 4:56 pm

To find all the fields I right clicked on the bundle and "inspected" it.

Here something to note: When an intent receiver receives the SMS notification, you can do very limited work within that handler for both timing (you must return within some small amount of time) and for thread conditions. In other words, I tried to get the values and Log.i() them but they did not show up in the Log display, until I spun a thread.start(), passing the bundle. The new separate thread happily logged the message. So, if you have trouble getting or displaying SMS data it might be because you can't do that in the context of the SMS Intent Receiver.

Ken
kenjkelly
kenjkelly
Freshman
Freshman
 
Posts: 7
Joined: Mon Oct 06, 2008 3:30 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests