我曾经用这样的代码,但不记得在那里我得到它:
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();
也许这将是使用到u的。它读取所有来自33300号码的短信 – Manny265
我使用该代码,它只给我发送给我的短信,但不是完整的对话。我真正想要的是发件人和我之间的完整对话。 –
我使用该代码,它只给我发送给我的短信,但不是完整的对话。我真正想要的是发件人和我之间的完整对话。 –