在查询 Android 的 MMS-SMSContent Provider
时,日期列对于 MMS 和 SMS 有不同的纪元时间值。
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
)按日期正确排序?