我有一個簡單的BroadcastReceiver,我在我的Activity的onResume方法中設置。Android:BroadcastManager是否有隊列?
@Override
protected void onResume() {
super.onResume();
LocalBroadcastManager.getInstance(this).registerReceiver(mNotificationReceiver, new IntentFilter(QuickstartPreferences.NEW_NOTIFICATION));
}
我註銷了接收器上的onPause:
@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mNotificationReceiver);
}
我有發送廣播消息,這個後臺服務:
Intent newNotification = new Intent(QuickstartPreferences.NEW_NOTIFICATION);
newNotification.putExtra("title", data.getString("title"));
LocalBroadcastManager.getInstance(this).sendBroadcast(newNotification);
我的問題是,如果後臺服務廣播活動未打開時的消息以及活動恢復時的消息,它是否能夠拾取廣播的消息?如果不是,當Activity未打開時如何維護隊列以存儲廣播的消息?
兩種選擇:使用'Notification's或「local bound Service」模式 – pskink