I\'m trying to send a broadcast from an IntentService to the activity that started it, this is how i register the Receiver in the activity:
private BroadcastRece
You should register
and unregister
your receivers in onResume()
and in onPause()
respectively. Cause if you only register it in onCreate()
and unregister in onPause()
, then the next time the activity is brought to the foreground, onCreate()
will not be called again and then it will not register the receiver again. But onResume()
is always called on the activity being displayed.
public void onResume() {
super.onResume();
....
registerReceiver(myBroadcastReceiver, intentFilter);
}
public void onPause() {
super.onPause();
...
unregisterReceiver(myBroadcastReceiver);
}