我曾經用這樣的代碼,但不記得在那裏我得到它:
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
我使用該代碼,它只給我發送給我的短信,但不是完整的對話。我真正想要的是發件人和我之間的完整對話。 –
我使用該代碼,它只給我發送給我的短信,但不是完整的對話。我真正想要的是發件人和我之間的完整對話。 –