我想在收到的短信(SMS)到达后立即阅读(在收到的广播上 - android.provider.Telephony.SMS_RECEIVED)。我实际上正在使用以下代码,但它只在收到之前读取消息。有人知道为什么吗?
public String getLastSms() {
resolver = context.getContentResolver();
uri = Uri.parse("content://sms/inbox");
projection = new String[]{"body"};
selection = null;
selectionArgs = null;
sortOrder = null;
cursor = resolver.query(uri, projection, selection, selectionArgs, sortOrder);
cursor.moveToFirst();
return cursor.getString(0);
}