I want to turn off wifi for battery save on some screen where I don't need it.
I tried this:
WifiManager wifiManager = (WifiManager) SensorApplication.getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager != null) wifiManager.setWifiEnabled(false);
That works fine to enable wifi. To disable wifi it works but something like 2s later wifi automatically turns back on. I tried to look at the dev options if something can explain this but I disable all option.
If someone has an idea for explain why wifi automatically turn on when I turn off with this solution, or has another solution to disable wifi that would be great.
Thanks in advance.