2016-08-16 95 views
0

我正在开发一个针对android的短信应用程序,我需要阅读发件人和收件人之间的对话。在Android中阅读短信会话

我试过了解我所知道的一切,但仍然无法做到。

Cursor c = getContentResolver(),query(Uri.parse("content://mms-sms/conversations?simple=true"), null,null,null,null); 

上面的代码没有给出两个人之间的对话。 请帮助我如何阅读对话。

回答

0

我曾经用这样的代码,但不记得在那里我得到它:

StringBuilder smsBuilder = new StringBuilder(); 
    final String SMS_URI_INBOX = "content://sms/inbox"; 
    final String SMS_URI_ALL = "content://sms/"; 
    try { 
     Uri uri = Uri.parse(SMS_URI_INBOX); 
     String[] projection = new String[]{"_id", "address", "person", "body", "date", "type"}; 
     Cursor cur = getActivity().getContentResolver().query(uri, projection, "address='33300'", null, "date desc"); 


     int index_Address = cur.getColumnIndex("address"); 
     int index_Person = cur.getColumnIndex("person"); 
     int index_Body = cur.getColumnIndex("body"); 
     int index_Date = cur.getColumnIndex("date"); 
     int index_Type = cur.getColumnIndex("type"); 
     String strAddress = cur.getString(index_Address); 
     int intPerson = cur.getInt(index_Person); 
     String strbody = cur.getString(index_Body); 
     long longDate = cur.getLong(index_Date); 
     int int_Type = cur.getInt(index_Type); 

     smsBuilder.append("[ "); 
     smsBuilder.append(strAddress + ", "); 
     smsBuilder.append(intPerson + ", "); 
     smsBuilder.append(strbody + ", "); 
     smsBuilder.append(longDate + ", "); 
     smsBuilder.append(int_Type); 
     smsBuilder.append(" ]\n\n"); 

     cur.close(); 
+0

也许这将是使用到u的。它读取所有来自33300号码的短信 – Manny265

+0

我使用该代码,它只给我发送给我的短信,但不是完整的对话。我真正想要的是发件人和我之间的完整对话。 –

+0

我使用该代码,它只给我发送给我的短信,但不是完整的对话。我真正想要的是发件人和我之间的完整对话。 –