当短信发送给我时。在BroatcastReceiver的onReceive中,我调用了readNewSMS()方法:
private MySMS readNewSMS(String phoneNumber) {
MySMS sms = new MySMS();
Uri uri = Uri.parse("content://sms/inbox");
Cursor cursor = getSherlockActivity().managedQuery(uri, null,
null, null, null);
cursor.moveToFirst();
sms.setNumber(cursor.getString(
cursor.getColumnIndexOrThrow("address")).toString());
sms.setId(cursor.getString(
cursor.getColumnIndexOrThrow("_id")).toString());
sms.setThread_id(cursor.getString(cursor
.getColumnIndexOrThrow("thread_id")));
sms.setBody(cursor.getString(
cursor.getColumnIndexOrThrow("body")).toString());
sms.setTime(cursor.getString(
cursor.getColumnIndexOrThrow("date")).toString());
sms.setType(cursor.getString(
cursor.getColumnIndexOrThrow("type")).toString());
return sms;
}
但它返回新短信的先前短信,而不是新短信。如何修复此错误?