Where to register a BroadcastReceiver (Activity lifecycle fun)
<p>Where's the right place to register/unregister an intent receiver in an Activity? Usually I would put stuff like this here:</p>

<pre><code>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);
    }
}
</code></pre>

<p>The problem is that my activity can then no longer respond to the broadcast if it happens while it's in the pause state. Where's the right place to do something like this then?</p>

<p>Thanks</p>
