我想在收到短信(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);
}
答案 0 :(得分:1)
您没有提供足够的背景信息。你的接收器是什么样的? 您是否看过像这样的完整示例:http://www.tutos-android.com/broadcast-receiver-android?