toggle WiFi enable or disable - Android android.net.wifi

Android examples for android.net.wifi:Wifi Enable

Description

toggle WiFi enable or disable

Demo Code

import android.content.*;
import android.net.wifi.*;
import java.lang.reflect.*;

public class Main{

    public static void toggleWiFi(Context context, boolean enabled) {
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        wifiManager.setWifiEnabled(enabled);
    }//from   w w w .  j av  a2  s  .c  o m

}

Related Tutorials