日期列的MMS和SMS之间的长度不同

时间:2013-01-06 06:56:26

标签: android date sms android-contentprovider mms

在查询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并获取按日期排序的所有邮件(MMSSMS)?

1 个答案:

答案 0 :(得分:2)

按日期排序邮件的方式,无论邮件是彩信还是短信,都将排序顺序更改为normalized_date,如下所示:

String sortOrder = "normalized_date";