可能重复:
How can I read SMS messages from the inbox programmatically in Android?
我想从Android设备获取所有收件箱短信。我该怎么做?
答案 0 :(得分:7)
您可以从以下方法获取收件箱邮件。
public List<String> getSMS(){
List<String> sms = new ArrayList<String>();
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null);
while (cur.moveToNext()) {
String address = cur.getString(cur.getColumnIndex("address"));
String body = cur.getString(cur.getColumnIndexOrThrow("body"));
sms.add("Number: " + address + " .Message: " + body);
}
return sms;
}