Turn on / off network settings on Android

Is there a (simple) ability to turn on / off the mobile network using Java code? If so, for mobile service too? Because I would like to make an application that turns the network on and off (or vice versa).

Thanks for the help.

+3
source share
2 answers

On a wireless network, you can enable the following code:

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(true);
+2
source

You need permissions to do this. I think CHANGE_WIFI_STATE is correct.

0
source

Source: https://habr.com/ru/post/1746250/


All Articles