Parsing SMS PDU
Asked Answered
H

2

3

Seems to be that I need to parse PDU byte array received during SMS BroadcastReceiver:

@Override
public void onReceive(Context context, Intent intent) 
{ 
    Bundle bundle = intent.getExtras();
    Object[] pdus = (Object[]) bundle.get("pdus");
}

Can someone point me how to do it?

I know that PDUs can be handled using SmsMessage.createFromPdu((byte[]) pdus[i]) but it's not what I'm looking for. I need more precise control over pdu bytes.

Hun answered 14/4, 2011 at 12:31 Comment(0)
H
2

I have found solution - there's nice Java and dot NET library (under Apache license), which handles all PDU related stuff - parsing and so on. It's SMSLib

Hun answered 22/5, 2011 at 18:34 Comment(2)
given link is broken.. hope we can use this code.google.com/archive/p/smslib/downloadsRabassa
can also be found at github.com/tdelenikas/smslib, though it says the project is no longer maintained.Retaliation
F
-1
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();

    SmsMessage[] msgs = null;

    if (bundle == null) return;

    Object[] pdus =  (Object[]) bundle.get("pdus");

    msgs = new SmsMessage[pdus.length];
    smsCount = msgs.length;
    String originalAddress;
    String tmpSmsBody;
    for (int i=0; i<msgs.length; i++){
        msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);

        // Original Address
        originalAddress = msgs[i].getOriginatingAddress();

        // Message body
        tmpSmsBody= msgs[i].getMessageBody().toString();
    }                
}
Fizzle answered 14/4, 2011 at 13:2 Comment(2)
please read my question carefully. I know about function createFromPdu() - it's not what I'm looking for!Hun
@barmaley If you want even more precise control, you should parse it by your own. You can search for the SMS standart.Fizzle

© 2022 - 2024 — McMap. All rights reserved.