package nl.rmokveld.castnotifications;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;

public class WifiStateReceiver extends BroadcastReceiver {

    private static final String TAG = "WifiStateReceiver";
    private Boolean mWasConnected;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
            Log.d(TAG, "onWifiStateChanged()");
            boolean isConnected = DeviceStateHelper.isWifiConnected(context);
            if (mWasConnected == null || mWasConnected != isConnected) {
                if (isConnected) {
                    CastNotificationManager.getInstance().getDiscoveryStrategy().onWifiConnected();
                } else {
                    CastNotificationManager.getInstance().getDiscoveryStrategy().onWifiDisconnected();
                }
                mWasConnected = isConnected;
            }
        }
    }
}

@@ -138,16 +138,48 @@
 Intent;%0A
+import android.net.NetworkInfo;%0A
 import a
@@ -207,16 +207,16 @@
 anager;%0A
-
 %0Apublic 
@@ -343,16 +343,23 @@
 ate 
+static 
 Boolean 
 mWas
@@ -354,17 +354,17 @@
 Boolean 
-m
+s
 WasConne
@@ -575,16 +575,113 @@
 ed()%22);%0A
+            NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);%0A
         
@@ -710,32 +710,22 @@
 d = 
-DeviceStateHelper.isWifi
+networkInfo.is
 Conn
@@ -730,23 +730,16 @@
 nnected(
-context
 );%0A     
@@ -749,17 +749,17 @@
     if (
-m
+s
 WasConne
@@ -774,17 +774,17 @@
 null %7C%7C 
-m
+s
 WasConne
@@ -798,32 +798,77 @@
  isConnected) %7B%0A
+                sWasConnected = isConnected;%0A
                 
@@ -1106,32 +1106,32 @@
 Disconnected();%0A
+
                 
@@ -1136,53 +1136,8 @@
   %7D%0A
-                mWasConnected = isConnected;%0A
     

Use a static field for tracking wifi connected state