Checks if WiFi is turned on<br>
Requires ACCESS_NETWORK_SATE, READ_PHONE_STATE permissions<br>

@return true if WiFi is turned on; false otherwise
556651
public boolean isWifiEnabled() {
		WifiManager wm = (WifiManager) context
				.getSystemService(Context.WIFI_SERVICE);
		if (wm == null) {
			return false;
		}

		return wm.isWifiEnabled();
	}
507234
@RequiresPermission(Manifest.permission.INTERNET)
  public static Single<Boolean> checkInternetConnectivity() {
    InternetObservingSettings settings = InternetObservingSettings.create();
    return checkInternetConnectivity(settings.strategy(), settings.host(), settings.port(),
        settings.timeout(), settings.httpResponse(), settings.errorHandler());
  }
196628
public static boolean isSpaEnabled() {
        Configuration config = ConfigUtils.getCurrentConfig();
        if (config != null) {
            return config.getBoolean(SPA_ENABLED_CONFIG_KEY, false);
        } else {
            return false;
        }
    }
994563
public void setWifiEnabled(Context context) {
		WifiManager wifiMan = (WifiManager) context
				.getSystemService(Context.WIFI_SERVICE);
		wifiMan.setWifiEnabled(true);
	}
642681
public boolean isConnected() {
    if (socket != null && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown())
      return true;
    return false;
  }
880620
def turn_on(self):
        """"""
        if self.device_status != 'on':
            body = helpers.req_body(self.manager, 'devicestatus')
            body['uuid'] = self.uuid
            body['status'] = 'on'
            head = helpers.req_headers(self.manager)

            r, _ = helpers.call_api('/131airPurifier/v1/device/deviceStatus',
                                    'put', json=body, headers=head)

            if r is not None and helpers.check_response(r, 'airpur_status'):
                self.device_status = 'on'
                return True
            else:
                return False
44147
public State getWifiState() {
		if (connMan == null) {
			connMan = (ConnectivityManager) context
					.getSystemService(Context.CONNECTIVITY_SERVICE);
		}
		NetworkInfo wifiNetworkInfo = connMan.getNetworkInfo(TYPE_WIFI);
		if (wifiNetworkInfo == null) {
			return State.UNKNOWN;
		}

		return wifiNetworkInfo.getState();
	}
1236704
public static boolean checkMobileDataState() throws Exception {
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) QuickUtils.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
            Class connectivityManagerClass = Class.forName(connectivityManager.getClass().getName());
            Method getMobileDataEnabled = connectivityManagerClass.getDeclaredMethod("getMobileDataEnabled");
            getMobileDataEnabled.setAccessible(true);

            return (Boolean) getMobileDataEnabled.invoke(connectivityManager);
        } catch(Exception e) {
            e.printStackTrace();
            throw new Exception("Unexpected exception. Please check stack trace");
        }
    }
1077396
public boolean isWifiConnected() {
		try {
			if (connMan == null) {
				connMan = (ConnectivityManager) context
						.getSystemService(Context.CONNECTIVITY_SERVICE);
			}
			NetworkInfo wifiNetInfo = connMan.getNetworkInfo(TYPE_WIFI);
			NetworkInfo wimaxNetInfo = connMan.getNetworkInfo(TYPE_WIMAX);

			if (wifiNetInfo == null && wimaxNetInfo == null) {
				Log.e(TAG, "wifiNetworkInfo is null.");
				return false;
			}

			if (wifiNetInfo != null && wifiNetInfo.isConnected()) {
				return true;
			}

			if (wimaxNetInfo != null && wimaxNetInfo.isConnected()) {
				return true;
			}
		} catch (Exception e) {
			Log.e(TAG,
					"Exception during isWifiConnected(). - "
							+ e.getLocalizedMessage());
		}
		return false;
	}
306295
def set_wifi_enabled(cls, state=True):
        
        app = AndroidApplication.instance()
        f = app.create_future()

        def on_permission_result(result):
            if not result:
                #: Permission denied
                f.set_result(None)
                return

            def on_ready(m):
                m.setWifiEnabled(state).then(f.set_result)

            WifiManager.get().then(on_ready)

        #: Check permission
        WifiManager.request_permission([
            WifiManager.PERMISSION_CHANGE_WIFI_STATE
        ]).then(on_permission_result)
        return f
26449
public function isEnabled()
    {
        if (null !== $this->getRequireRouteName())
        {
            if ($this->getInvertRequireRouteName() XOR ($this->getCurrentRouteName() != $this->getRequireRouteName()))
            {
                return false;
            }
        }

        return $this->enabledIfRoleMissing || $this->userHasRequiredRole();
    }
104494
function isSocketConnected(socket) {
       return socket && (
            (socket.socket && socket.socket.connected) || socket.connected
        );
    }
17364
public static boolean isNetworkConnected(Context context) {
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info = manager.getActiveNetworkInfo();
        return info != null && info.isConnected();
    }
529199
public function isEnabled()
    {
        $result = $this->enabled;
        if (is_callable($result)) {
            $result = $result($this);
        }

        return (bool) $result;
    }
678460
public void setWiFiData(Boolean turnedOn){
		WifiManager wifiManager = (WifiManager)instrumentation.getTargetContext().getSystemService(Context.WIFI_SERVICE);
		try{
			wifiManager.setWifiEnabled(turnedOn);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
446712
final public function isEnabled() {
		
		if ($this->disabled) {
			return FALSE;
		}
		
		$app = Application::getInstance();
		$router = Router::getInstance();
		
		// no logs on command line and web API
		if ('cli' == php_sapi_name() or 'api' == $router->module) {
			
			return FALSE;
			
		// user is defined, could be admin
		} else if ($app->currentUser) {
			
			return (Options::get('show_log') and $app->currentUser->admin);
		
		// no logs on login page
		} else if ('user' == $router->module and 'login' == $router->action) {
				
			return FALSE;
					
		// no login, no user defined, collects logs
		} else {
			
			return TRUE;
			
		}
		
	}
657849
private void getNetworkInfo() {
		// Create a listener to check for new network connections (e.g. switching from mobile to Wifi, or losing internet connection)
		NetworkConnectionListener listener = new NetworkConnectionListener() {

			@Override
			public void networkChanged(NetworkConnectionType newConnection) {
				Log.i("BMSCore", "New network connection: " + newConnection.toString());
			}
		};

		// Initilize the network monitor with the application context and network change listener
		this.networkMonitor = new NetworkMonitor(getApplicationContext(), listener);

		// Start listening for network changes
		networkMonitor.startMonitoringNetworkChanges();

		// See if the device currently has internet access, and see what type of connection it is using
		Log.i("BMSCore", "Is connected to the internet: " + networkMonitor.isInternetAccessAvailable());
		Log.i("BMSCore", "Connection type: " + networkMonitor.getCurrentConnectionType().toString());

		// Check that the user has given permissions to read the phone's state.
		// If permission is granted, get the type of mobile data network being used.
		int networkPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
		if (networkPermission == PackageManager.PERMISSION_GRANTED) {
			Log.i("BMSCore", "Mobile network type: " + networkMonitor.getMobileNetworkType());
		}
		else {
			Log.i("BMSCore", "Obtaining permission to read phone state");
			if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
				// Asynchronously explain to the user why you are attempting to request this permission.
				// Once this is done, try to request the permission again.
			}
			else {
				ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, MY_PERMISSIONS_READ_PHONE_STATE);
			}
		}
	}