FileDocCategorySizeDatePackage
MessageStatusReceiver.javaAPI DocAndroid 1.5 API3143Wed May 06 22:42:46 BST 2009com.android.mms.transaction

MessageStatusReceiver

public class MessageStatusReceiver extends android.content.BroadcastReceiver

Fields Summary
public static final String
MESSAGE_STATUS_RECEIVED_ACTION
private static final String[]
ID_PROJECTION
private static final String
LOG_TAG
private static final android.net.Uri
STATUS_URI
private android.content.Context
mContext
Constructors Summary
Methods Summary
private voiderror(java.lang.String message)

        Log.e(LOG_TAG, "[MessageStatusReceiver] " + message);
    
public voidonReceive(android.content.Context context, android.content.Intent intent)


    
          
        mContext = context;
        if (MESSAGE_STATUS_RECEIVED_ACTION.equals(intent.getAction())) {

            Uri messageUri = intent.getData();
            byte[] pdu = (byte[]) intent.getExtra("pdu");

            updateMessageStatus(context, messageUri, pdu);
            MessagingNotification.updateNewMessageIndicator(context, true);
       }
    
private voidupdateMessageStatus(android.content.Context context, android.net.Uri messageUri, byte[] pdu)

        // Create a "status/#" URL and use it to update the
        // message's status in the database.
        Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
                            messageUri, ID_PROJECTION, null, null, null);
        if ((cursor != null) && cursor.moveToFirst()) {
            int messageId = cursor.getInt(0);

            cursor.close();

            Uri updateUri = ContentUris.withAppendedId(STATUS_URI, messageId);
            SmsMessage message = SmsMessage.createFromPdu(pdu);
            int status = message.getStatus();
            ContentValues contentValues = new ContentValues(1);

            contentValues.put(Sms.STATUS, status);
            SqliteWrapper.update(context, context.getContentResolver(),
                                updateUri, contentValues, null, null);
        } else {
            error("Can't find message for status update: " + messageUri);
        }