Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 以编程方式将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权限.

快乐编码:)

大佬总结

以上是大佬教程为你收集整理的android – 以编程方式将MMS标记为已读全部内容,希望文章能够帮你解决android – 以编程方式将MMS标记为已读所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。