在查询Android的MMS-SMS Content Provider
时,日期列的MMS有不同的纪元时间值,而不是短信。
ContentResolver contentResolver = getContentResolver();
final String[] projection = new String[] { "body", "person", "sub",
"subject", "retr_st", "type", "date" + " as " + "d", "ct_cls", "sub_cs",
"_id", "read", "ct_l", "st", "msg_box", "reply_path_present",
"m_cls", "read_status", "ct_t", "status", "retr_txt_cs",
"d_rpt", "error_code", "m_id", "date_sent", "m_type", "v",
"exp", "pri", "service_center", "address", "rr", "rpt_a",
"resp_txt", "locked", "resp_st", "m_size" };
String sortOrder = "date";
Uri uri = Uri.parse("content://mms-sms/conversations/");
Cursor c = contentResolver.query(uri, projection, null, null, sortOrder);
String messageDate = c.getString(c.getColumnIndex("date"));
在MMS
的情况下,在messageDate变量中保存的纪元时间是10位数。但是,在SMS
的情况下,在messageDate变量中保存的纪元时间长度为13位。
尝试按日期排序时出现此问题,因为MMS
消息在按日期排序时显示在SMS
消息之前。
有没有办法查询此Content Provider
并获取按日期排序的所有邮件(MMS
或SMS
)?
答案 0 :(得分:2)
按日期排序邮件的方式,无论邮件是彩信还是短信,都将排序顺序更改为normalized_date
,如下所示:
String sortOrder = "normalized_date";