I know regular Android rules (unfortunately) restricted apps from being able to toggle the Wifi state as stated here. But I found in Samsung, under Special Access, the option “Wi-Fi control”. There, my app can be allowed to control wifi. It says “Allow this app to turn Wi-Fi on or off…”
I did that but I am not able to turn Wi-Fi on or off. I tried with this code:
WifiManager mWifiManager = (WifiManager) myContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
mWifiManager .setWifiEnabled(true or false);
But it does nothing. Wifi is not turned on or off. Any help on this?