Приведенный ниже код работает для меня, чтобы обновить, помечено ли MMS-сообщение как просмотренное или нет.
Чтобы использовать это с SMS-сообщениями, просто замените следующее «content: // mms /» этим «content: // sms /».
/**
* Mark a single SMS/MMS message as being read or not.
*
* @param context - The current context of this Activity.
* @param messageID - The Message ID that we want to alter.
*
* @return boolean - Returns true if the message was updated successfully.
*/
public static boolean setMessageRead(Context context, long messageID, boolean isViewed){
try{
if(messageID == 0){
return false;
}
ContentValues contentValues = new ContentValues();
if(isViewed){
contentValues.put("READ", 1);
}else{
contentValues.put("READ", 0);
}
String selection = null;
String[] selectionArgs = null;
_context.getContentResolver().update(
Uri.parse("content://mms/" + messageID),
contentValues,
selection,
selectionArgs);
return true;
}catch(Exception ex){
return false;
}
}
Кроме того, вам может потребоваться одно из разрешений SMS в файле манифеста Android.
Удачного кодирования:)