這是我用來在上下文菜單中按下查看按鈕時閱讀收件箱郵件的代碼,但我無法閱讀郵件,我只收到第一封郵件的正文。如何從收件箱中讀取郵件
public class Smsread extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView view = new TextView(this);
Uri uri = Uri.parse("content://sms/inbox");
Cursor c= getContentResolver().query(uri, null, null ,null,null);
startManagingCursor(c);
String sms = "";
if(c.moveToFirst()){
for(int i=0;i<c.getCount();i++){
sms= c.getString(c.getColumnIndexOrThrow("body")).toString();
// sms=c.getString(c.getColumnIndexOrThrow("address")).toString();
}
c.close();
c.moveToNext();
/*
sms ="From :" + c.getString(2) + " : " + c.getString(11)+"\n";
*/
}
view.setText(sms);
setContentView(view);
}
}
很好的回答短期和甜+1 – 2012-02-23 06:23:22
@parag:感謝.. :) – Hiral 2012-02-23 06:27:57
@parag :感謝parag你說的邏輯是正確的,但我嘗試在我的程序中應用相同的,但仍然當我按下查看按鈕爲e ach消息我得到相同的第一條消息的主體。 – dippu 2012-02-26 05:30:26