MessageStatusReceiverpublic 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 |
Methods Summary |
---|
private void | error(java.lang.String message)
Log.e(LOG_TAG, "[MessageStatusReceiver] " + message);
| public void | onReceive(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 void | updateMessageStatus(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);
}
|
|