Code example for WifiManager

Methods: getConnectionInfogetWifiStateisWifiEnabled

0
				 
		get_wifi(); 
	} 
	 
	private void get_wifi() { 
		WifiInfo info = wifi.getConnectionInfo();
		int state = wifi.getWifiState();
		int strength = WifiManager.calculateSignalLevel(info.getRssi(), 5);
		boolean enabled = wifi.isWifiEnabled();
		 
		name_label.setText(info.getSSID());
		enable_label.setText(enabled ?"Your wifi is enabled" :"Your wifi is not enabled");
		state_button.setText(enabled ?"Disable wifi" : "Enable wifi");
		 
		switch(state) {
			case WifiManager.WIFI_STATE_ENABLED:
				data_labels[WIFISTATE].setText(" Enabled");
				break; 
			case WifiManager.WIFI_STATE_DISABLED:
				data_labels[WIFISTATE].setText(" Disabled");
				break;