我想廣播只爲特定的活動。如果活動破壞,則廣播不會觸發。 我使用這樣的如何使廣播只爲特定的活動生活在android
protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver((receiver),
new IntentFilter(GCMIntentService.COPA_RESULT)
);
}
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int count = intent.getIntExtra(GCMIntentService.COPA_MESSAGE, 0);
int youCount = intent.getIntExtra(GCMIntentService.COUNT_YOU, 0);
int reqCount = intent.getIntExtra(GCMIntentService.COUNT_REQ, 0);
if (count != 0) {
notificationcount.setVisibility(View.VISIBLE);
notificationcount.setText("" + count);
} else {
notificationcount.setVisibility(View.GONE);
}
AppCommon.notification_requestcount = reqCount;
AppCommon.notification_youcount = youCount;
AppCommon.notification_total_count = count;
}
};
什麼我失蹤如果你想這樣做,則請提出這個
您嘗試過什麼嗎?如果是這樣,那麼編輯這個問題,以節省投票! – OBX
您是否嘗試在您的活動中接收或發送廣播? –
考慮接受一個答案,如果幫助..! – W4R10CK