title: How to unregister receiver attached to LocalBroadcastManager?
body: <p>How to unregister receiver attached to LocalBroadcastManager?</p>
  
  <p>I tried </p>
  
  <pre><code>unregisterReceiver(broadcastReceiver);
  </code></pre>
  
  <p>but it gave me an exception</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Receiver not registered:</p>
  </blockquote>
  
  <p>This is my code</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      init();
      locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
      LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiverCancelPd, new IntentFilter(PelicanApplication.identifierCancelPd));
      LocalBroadcastManager.getInstance(this).registerReceiver(bReceiverSignOut, new IntentFilter(PelicanApplication.identifierSignOut));
      LocalBroadcastManager.getInstance(this).registerReceiver(bReceiverNearByDeliveries, new IntentFilter(PelicanApplication.identifierNBD));
  }
  
  
  @Override
  protected void onStop() {
      super.onStop();
      unregisterReceiver(broadcastReceiverCancelPd);
      unregisterReceiver(bReceiverSignOut);
      unregisterReceiver(bReceiverNearByDeliveries);
  }
  </code></pre>