Code example for AtomicBoolean

0
import com.android.settings.WirelessSettings; 
 
import java.util.concurrent.atomic.AtomicBoolean; 
 
public class WifiEnabler implements CompoundButton.OnCheckedChangeListener  {
    private final Context mContext;
    private Switch mSwitch;
    private AtomicBoolean mConnected = new AtomicBoolean(false);
 
    private final WifiManager mWifiManager;
    private boolean mStateMachineEvent;
    private final IntentFilter mIntentFilter;
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override 
        public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction(); 
            if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) { 
                handleWifiStateChanged(intent.getIntExtra( 
                        WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN)); 
            } else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) { 
                if (!mConnected.get()) {