1

OK folks,

  1. I know how to intercept SMS and/or MMS receiver broadcasts
  2. I know how to parse SMS pdu
  3. I know how to save MMS and SMS to device storage

Only missing moment for me is how to parse MMS PDU and get binary data and its mime type.

Can anyone point me to good resource/example or just explain how to do it?

public class MmsReceiver extends BroadcastReceiver {
  private static final String PDUS = "pdus";

  @Override
  public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Object[] pdus = (Object[]) bundle.get(PDUS); //getting PDU's from extras

    //what next??

  }
}
Barmaley
  • 16,638
  • 18
  • 73
  • 146
  • This post might be useful to you: http://stackoverflow.com/a/6446831/2445061 – ChrisCarneiro Mar 26 '14 at 08:42
  • @ChrisCarneiro nope it's useless, it's only about reading/writing to device storage. I'm looking for parsing of PDU received in `BroadcastReceiver` – Barmaley Mar 26 '14 at 08:47

2 Answers2

0

You want to do something like

SendReq parsed = (SendReq) new PduParser(pduByteArray).parse();

if for example, it's an outgoing MMS SendReq; if it's an incoming one I believe you want to cast to a RetrieveConf instead. Then there are accessors etc. to pick it apart.

Sadly, the toString() on those objects doesn't give you anything particularly useful (we can dream!)

In the RetrieveConf, you can call getContentType() which returns an array of the types in the message. To get the actual binary data, I think you might need to go directly to the system content store tables, though; I don't think the full binary data is stored in the PDU object (even though it might have been sent that way on the wire; I think it gets stashed into the system databases as soon as it arrives, parted out into individual objects).

Ben M
  • 47
  • 2
-2
    SmsMessage[] sms = new SmsMessage[pdus.length];
    sms[0] = SmsMessage.createFromPdu((byte[]) pdus[0]);
Mohammad Lotfi
  • 369
  • 5
  • 16