Android examples for android.net.wifi:Wifi Enable
enable All Networks
import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.util.Log; import java.net.InetAddress; import java.util.List; public class Main{ private static final String TAG = WifiUtils.class.getSimpleName(); private static void enableAllNetworks() { try {/*ww w. j a va 2 s .c om*/ WifiManager wifiManager = getWifiManager(); List<WifiConfiguration> configuredNetworks = wifiManager .getConfiguredNetworks(); for (WifiConfiguration conf : configuredNetworks) { if (conf.status == WifiConfiguration.Status.DISABLED) { Log.i(TAG, "Network " + conf.SSID + " was disabled: " + new WifiConfigurationWrapper(conf) .getDisableReason()); wifiManager.enableNetwork(conf.networkId, false); } } } catch (Exception ignored) { } } public static WifiManager getWifiManager() throws Exception { if (sWifiManager == null) { sWifiManager = (WifiManager) sContext .getSystemService(Context.WIFI_SERVICE); } if (!sWifiManager.isWifiEnabled()) { sWifiManager.setWifiEnabled(true); } return sWifiManager; } }