Get message status for delivery report from pdu

This commit is contained in:
Mathieu Maret 2013-09-11 15:05:12 +02:00
parent 5e5fd482cf
commit d32829784a

View File

@ -5,6 +5,7 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.telephony.SmsMessage;
public class MessageReceiver extends BroadcastReceiver{ public class MessageReceiver extends BroadcastReceiver{
public static final String MESSAGE_RECEIVED = "com.hectorone.multismssender.SMS_RECEIVED"; public static final String MESSAGE_RECEIVED = "com.hectorone.multismssender.SMS_RECEIVED";
@ -20,9 +21,17 @@ public class MessageReceiver extends BroadcastReceiver{
Uri entryURI = intent.getData(); Uri entryURI = intent.getData();
if (entryURI != null){ if (entryURI != null){
byte[] pdu = intent.getByteArrayExtra("pdu");
//createFromPdu (byte[] pdu) will be deprecated.
//Use following instead
//String format = intent.getStringExtra("format");
//SmsMessage message = SmsMessage.createFromPdu(pdu, format);
SmsMessage message = SmsMessage.createFromPdu(pdu);
if(message.getStatus()== 0) {
ContentValues values = new ContentValues(1); ContentValues values = new ContentValues(1);
values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_DELIVERED, 1); values.put(DeliveryDbAdapter.KEY_DELIVERY_ENTRY_DELIVERED, 1);
context.getContentResolver().update(entryURI, values, null, null); context.getContentResolver().update(entryURI, values, null, null);
}
} }
} }