Retreive在Android设备上的所有收件箱meseges [英] Retreive all inbox meseges of device in android
本文介绍了Retreive在Android设备上的所有收件箱meseges的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用这code。
Object[] pduArray = (Object[]) intent.getExtras().get("pdus");
SmsMessage[] messages = new SmsMessage[pduArray.length];
StringBuilder messageText = new StringBuilder();
for (int i = 0; i < pduArray.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pduArray [i]);
messageText.append(messages[i].getMessageBody());
}
但是,这code仅供亲密短信时,在装置收到,但我的需求是中检索它被保存在安卓Android设备我该怎么做到这一切的收件箱中的邮件?
But this code is for only intimate when sms is recieved in a device but my need is to retreive all inbox messages which is saved in android device in android how can I do it?
推荐答案
试试这个code:
Uri SMSURI = Uri.parse("content://sms/inbox");
String[] projection = new String[]{"_id", "address", "body", "date"};
Cursor cursor = null;
try {
cursor = getContentResolver().query(SMSURI
, projection
, null //selection
, null //selectionArgs
, null); //sortOrder
if (cursor != null && cursor.moveToFirst()) {
do {
int id = cursor.getInt(cursor.getColumnIndex("_id"));
String address = cursor.getString(cursor.getColumnIndex("address"));
String body = cursor.getString(cursor.getColumnIndex("body"));
String date = cursor.getString(cursor.getColumnIndex("date"));
Toast.makeText(getBaseContext(), "Message is >>"+body,
Toast.LENGTH_SHORT).show();
}
} while (cursor.moveToNext());
}
} finally {
if (cursor != null) {
cursor.close();
}
}
这篇关于Retreive在Android设备上的所有收件箱meseges的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文