title: aused by: java.lang.IllegalArgumentException: Receiver not registered: null
body: <p>I am trying to register broad for internet connection and wifi scan results but I am getting this error."caused by: java.lang.IllegalArgumentException: Receiver not registered: null". The internet conccection broadcast works but not the of the wifi scan result.
  I Appreciate any help.</p>
  
  <p>MainActivity:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class MainActivity extends ActionBarActivity {
   BroadcastReceiverListener receiver;
  
   @Override
   protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
          receiver = new BroadcastReceiverListener();
  
   }
  
   private class BroadcastReceiverListener extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
     if (intent.getAction().equals(
       android.net.wifi.WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
  
     }
  
     else if (intent.getAction().equals(
       android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
  
     }
    }
   };
  
   protected void onResume() {
  
   
  
    IntentFilter wifi = new IntentFilter();
    wifi.addAction(android.net.wifi.WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
    registerReceiver(receiver, wifi);
  
    IntentFilter conn = new IntentFilter();
    conn.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(receiver, conn);
  
    super.onResume();
   }
  
   @Override
   protected void onDestroy() {
    unregisterReceiver(receiver);
    super.onDestroy();
   }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Mainfest:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.bustracker"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="21" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  
      &lt;!-- Enable to check if the wifi is available --&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".BCR"
              android:label="@string/title_activity_bcr" &gt;
          &lt;/activity&gt;
  
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;</code></pre>
  </div>
  </div>
  </p>