我们在学习或设计不同通讯用户之间的会话时,常常会使用到手机系统中的短消息会话机制,作为一名移民IT民工初学者,就我最近所用到的有关手机短信会话机制中的URI及部分URI返回数据做下分享,忘指正:
一、 短信会话Uri
public static final Uri CONVERSATION_URI = Uri.parse("content://mms-sms/conversations");
二、短信Uri 对应的ContentProvider会协调处理短信的收件箱和发件箱
public static final Uri SMS_URI = Uri.parse("content://sms");
2.1 、短信发件箱:
public static final Uri SMS_SEND_URI = Uri.parse("content://sms/sent");
2.2、短信收件箱:
public static final Uri SMS_INBOX_URI = Uri.parse("content://sms/inbox");
我们通常可以自己设计一个test继承AndroidTestCase类的自定义类来测试我们所写代码的正确性或者所写代码所获得的数据:
如下为短信会话uri返回的数据:content://mms-sms/conversations
该uri返回如此之多的列,我们完全可以根据业务需求,检索自己所需要的列(通常在用户对话过程所需要的列为:body, date, read, thread_id, address)
07-06 20:21:05.177: I/TAG(29460): body:Easy,easy,boy,just for fun -----该句短信内容
07-06 20:21:05.177: I/TAG(29460): person:null
07-06 20:21:05.177: I/TAG(29460): text_only:null
07-06 20:21:05.177: I/TAG(29460): sub:null
07-06 20:21:05.177: I/TAG(29460): subject:null
07-06 20:21:05.177: I/TAG(29460): retr_st:null
07-06 20:21:05.177: I/TAG(29460): type:2
07-06 20:21:05.177: I/TAG(29460): date:1467773409780 ------短信时间
07-06 20:21:05.187: I/TAG(29460): ct_cls:null
07-06 20:21:05.187: I/TAG(29460): sub_cs:null
07-06 20:21:05.187: I/TAG(29460): _id:16
07-06 20:21:05.187: I/TAG(29460): read:1 ----短信的阅读状态(0为未读,1为已读)
07-06 20:21:05.187: I/TAG(29460): ct_l:null
07-06 20:21:05.187: I/TAG(29460): tr_id:null
07-06 20:21:05.187: I/TAG(29460): st:null
07-06 20:21:05.187: I/TAG(29460): msg_box:null
07-06 20:21:05.187: I/TAG(29460): thread_id:2 ---该句短信属于哪一组会话
07-06 20:21:05.187: I/TAG(29460): reply_path_present:null
07-06 20:21:05.187: I/TAG(29460): m_cls:null
07-06 20:21:05.187: I/TAG(29460): read_status:null
07-06 20:21:05.187: I/TAG(29460): ct_t:null
07-06 20:21:05.187: I/TAG(29460): status:-1
07-06 20:21:05.187: I/TAG(29460): retr_txt_cs:null
07-06 20:21:05.197: I/TAG(29460): d_rpt:null
07-06 20:21:05.197: I/TAG(29460): error_code:0
07-06 20:21:05.197: I/TAG(29460): m_id:null
07-06 20:21:05.197: I/TAG(29460): date_sent:0
07-06 20:21:05.197: I/TAG(29460): m_type:null
07-06 20:21:05.197: I/TAG(29460): v:null
07-06 20:21:05.197: I/TAG(29460): exp:null
07-06 20:21:05.197: I/TAG(29460): pri:null
07-06 20:21:05.197: I/TAG(29460): service_center:null
07-06 20:21:05.197: I/TAG(29460): address:01 ----会话的号码
07-06 20:21:05.197: I/TAG(29460): rr:null
07-06 20:21:05.197: I/TAG(29460): rpt_a:null
07-06 20:21:05.197: I/TAG(29460): resp_txt:null
07-06 20:21:05.197: I/TAG(29460): locked:0
07-06 20:21:05.207: I/TAG(29460): resp_st:null
07-06 20:21:05.207: I/TAG(29460): m_size:null
通过以上试验检索所得,我们可以很明确的得到自己所需信息,以便我们在接下来的设计中准确书写获得业务所需内容的方法