3
是否有更新MMS/SMS数据库以将消息从读取标记为未读消息,反之亦然?我试过使用URI,但他们不适合我。以编程方式标记MMS
是否有更新MMS/SMS数据库以将消息从读取标记为未读消息,反之亦然?我试过使用URI,但他们不适合我。以编程方式标记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;
}
}
此外,您可能需要在您的Android清单文件中有一个SMS权限。
快乐编码:)