0
我有一個arraylist有一些聯繫號碼,我想通過該arraylist尋址。這樣它會從選擇列表中選定的數字中獲得所有消息。 預先感謝您。如何從多個發件人中讀取收件箱中的所有短信,但不是所有發件人都在android中?
StringBuilder smsBuilder = new StringBuilder();
final String SMS_URI_INBOX = "content://sms/inbox";
final String SMS_URI_ALL = "content://sms/";
Uri uri = Uri.parse(SMS_URI_INBOX);
String[] projection = new String[] { "_id", "address", "person", "body", "date", "type" };
Cursor cur = getContentResolver().query(uri, projection, "address='"+list+"'" , null, "date desc");
if (cur.moveToFirst())
{
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");
do
{
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);
String str = "SMS From: " + cur.getString(index_Address) +
"\n" + cur.getString(index_Body) + "\n";
arrayAdapter.add(str);
smsBuilder.append("[ ");
smsBuilder.append(strAddress + ", ");
smsBuilder.append(intPerson + ", ");
smsBuilder.append(strbody + ", ");
smsBuilder.append(longDate + ", ");
smsBuilder.append(int_Type);
smsBuilder.append(" ]\n\n");
} while (cur.moveToNext());
if (!cur.isClosed())
{
cur.close();
cur = null;
}
}
else
{
smsBuilder.append("no result!");
} // end if
}
這哪裏是'在你的代碼編號的ArrayList'? – pleft
可能重複[獲取特定電話號碼的短信](https://stackoverflow.com/questions/14721772/get-sms-of-specific-phone-number) – pleft
不,我問的是如何通過多個聯繫人號碼來解決? @pleft –