您好,我正在尝试将所有短信标记为在 Android 上已读 我尝试了所有可行的解决方案,但我不能似乎我有问题 我尝试了以下解决方案
- Android: how to mark sms as read in onReceive Set sms as read in Android http://looksok.wordpress.com/2013/09/07/android-tutorial-mark-sms-as-read-unread/
这是我的代码
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 - 将短信标记为已读 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23451060/