How to enable and disable Wifi in ANDROID?

The WifiManager can be used to enable and disable wifi. Where ‘enabled’ is a boolean.

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(enabled);