In what place should the registrant of intent be registered / deregistered with the Office? I would usually add the following here:
class MyActivity
{
private BroadcastReceiver mMyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, "Do something.");
}
};
@Override
public void onResume() {
super.onResume();
registerReceiver(mMyReceiver, new IntentFilter(...));
}
@Override
public void onPause() {
super.onPause();
unregisterReceiver(mMyReceiver);
}
}
The problem is that my activity may stop responding to the broadcast if this happens when it is in a pause state. Where is the right place for something like this?
thank
source
share