0
可能重複所有消息:
How to access the SMS storage on Android?我怎麼能訪問在Android
你好我試圖訪問Android的所有消息。我有代碼,但我只通過此代碼訪問最後一條消息。怎麼讀全部?
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
if (bundle != null)
{
String header = "";
String body = "";
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++)
{
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
header = msgs[i].getOriginatingAddress();
body = msgs[i].getMessageBody().toString();
}
//---display the new SMS message---
Toast.makeText(context,"Mesaj geldi", Toast.LENGTH_SHORT).show();
Header.add(header);
Body.add(body);
}
可能重複[如何訪問Android上的短信存儲?](http://stackoverflow.com/questions/4809874/how-to-access-the-sms-storage-on-android)和http://stackoverflow.com/questions/848728/how-cani-i-從消息接收器讀取短消息從編程方式在Android – nandeesh
這是一個消息接收器。訪問短信數據庫,請參閱http://stackoverflow.com/questions/4809874/how-to-access-the-sms-storage-on-android – njzk2
謝謝,但我沒有在您的接收器中找到.. –