title: Can't unregistering Broadcast Receiver in Android?
body: <p>I have a broadcast receiver that I try to unregister in the <code>OnPause()</code> method. But then it gets blocked it seems, and although I register it in the <code>OnResume()</code>, it doesn't fire. If I only register it it works well, but then I get the exception "leaking broadcast receiver, you should unregister it", as below: </p>
  
  <pre><code>06-04 22:50:04.267: ERROR/ActivityThread(4188): Activity com.example.android.CView has leaked IntentReceiver com.example.android.CView$1@4062b650 that was originally registered here. Are you missing a call to unregisterReceiver()?
  06-04 22:50:04.267: ERROR/ActivityThread(4188): android.app.IntentReceiverLeaked: Activity com.example.android.CView has leaked IntentReceiver com.example.android.CVieww$1@4062b650 that was originally registered here. Are you missing a call to unregisterReceiver()?
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at android.app.LoadedApk$ReceiverDispatcher.&lt;init&gt;(LoadedApk.java:790)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:575)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:848)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:835)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:829)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at cActivity com.example.android.BehaviourView.onStart(BehaviourView.java:230)
  06-04 22:50:04.267: ERROR/ActivityThread(4188):     at 
  </code></pre>
  
  <p>There are tons of posts concerning this, and I have tried many of them without results. The practice is to register it in <code>OnResume</code> and unregister it in the <code>OnPause</code>, right? Or should I unregister it in <code>onStop()</code>. I have tried and then it never listens. </p>
  
  <p>Thanks for any pointers!</p>