如果用户阅读 SMS(来自 native ),除了“已读”之外,SMS 的任何其他属性是否也会被修改?
例如:
int read_status = cur1.getInt(cur1.getColumnIndex("read"));
read_status 将变为 1 表示读取短信。
请指导我。
最佳答案
下面的代码将允许您通过打印出 SMS 内容提供程序返回的所有消息的列和相应值来确定除“已读”之外的任何其他属性是否正在更改。根据我在运行 Android 4.1.2 JZO54K 的 Nexus S 上运行的快速测试,不幸的是,当 SMS 从未读状态变为已读状态时,似乎没有其他值被修改。
不过,有一个相关的“已见”属性可能很有趣。当 SMS 已呈现给用户但可能在消息内容被读取之前(例如,当显示在 native 消息应用程序的摘要 View 中时),它会从 0 变为 1。通过查看 com.android.mms.data.Conversation 中的用法,可以进一步理解“看到”和“阅读”之间的关系。类。
也可以使用 android.telephony.SmsMessage.getStatusOnIcc() 方法检索读取状态,但这可能会为您提供您已经从内容提供程序检索的相同信息。 您可能希望跟踪 Google is indicating will be coming in Android 4.4 (KitKat) 对 SMS API 的更改因为它们可以帮助解决您试图解决的问题,但如果它依赖于隐藏的 API/内容提供商,它们也可能会破坏您现有的实现。
/* for use within a ContentObserver class; print all messages & fields
from the SMS Content Provider when change to mmssms.db is detected;
not optimized for production use */
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Uri uri = Uri.parse("content://sms/inbox");
Cursor c= getContentResolver().query(uri,null,null,null,null);
if(c.moveToFirst()){
for(int i=0;i<c.getCount();i++){
Log.d(TAG,"======= Message ID "+c.getString(c.getColumnIndexOrThrow("_id")).toString()+" =======");
for (int j=0;j<c.getColumnCount();j++){
Log.d(TAG,c.getColumnName(j)+" = "+c.getString(j));
}
}
}
}
}
关于android - 如果用户阅读 SMS(来自 native )(不包括 "read"),SMS 的任何其他属性是否也会被修改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19335760/