2012-09-18 79 views

回答

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; 

    }