title: BroadcastReceiver Wifi disabled
body: <p>I want my application to give a notification when wifi goes 'offline'. </p>
  
  <p>I figured out the notification part. But I can't seem to figure out the 'wifi check'-part.
  I read something about BroadcastReceiver but I can't seem to get it working. Any useful links? or example code? Tutorials?  </p>
  
  <p>Thanks in advance!</p>
  
  <p>Updated with code. Its working but I need it to only give a notification when wifi goes offline. </p>
  
  <pre><code>    public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {        
  
      super.onCreate(savedInstanceState);  
      this.registerReceiver(this.mConnReceiver,
              new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
      setContentView(R.layout.activity_main);
  }
  
  private BroadcastReceiver mConnReceiver = new BroadcastReceiver() {
      public void onReceive(Context context, Intent intent) {
          boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
          String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
          boolean isFailover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);
  
          NetworkInfo currentNetworkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
          NetworkInfo otherNetworkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
  
          if(currentNetworkInfo.isConnected()){
  
          }else{
              showNotification();
          }
      }
  };
  </code></pre>