【问题标题】:mark SMS as read android将短信标记为已读 android
【发布时间】:2014-05-03 23:56:00
【问题描述】:

您好,我正在尝试在 android 上将所有短信标记为已读 我尝试了所有可行的解决方案,但我似乎没有什么问题 我尝试了以下解决方案

这是我的代码

     protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_smslist);
            markSmsAsRead();
            setSMSRead();
    }

 public void markSmsAsRead() {

        Uri uri = Uri.parse("content://sms/inbox");
        String selection = "read = ?";
        String[] selectionArgs = {"0"};

        ContentValues values = new ContentValues();
        values.put("read", true);
        Context context = getApplicationContext();
        context.getContentResolver().update(uri, values, selection, selectionArgs);
    }
    public void setSMSRead()
    {
        ContentValues values = new ContentValues();
        values.put("read", true);
       // String where = "read = 0";
       // String where = "_id < 100000";
        Context context = getApplicationContext();
        context.getContentResolver().update(Uri.parse("content://sms/inbox"), values, "_id<" + "100000", null);

    }

【问题讨论】:

标签: android sms android-contentresolver


【解决方案1】:

为了将短信标记为已读,您的应用必须是默认短信应用

【讨论】:

猜你喜欢
  • 2012-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-08
  • 1970-01-01
相关资源
最近更新 更多