1、需要申请的权限
android.permission.ACCESS_WIFI_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.WAKE_LOCK
2、获取WifiManager
wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
3、开启、关闭wifi
if (wifiManager.isWifiEnabled()) {
wifiManager.setWifiEnabled(false);
} else {
wifiManager.setWifiEnabled(true);
}