Turning on/off network settings on Android
Is there a (simple) possibility for turning the mobile network on/off with Java code? If so, for mobile service too? 'Cause开发者_JS百科 I'd like to make an app which turns the network on and service off (or the opposite).
Thanks for help.
The wireless network you can turn on by the following code:
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(true);
You need permissions to do that. I think CHANGE_WIFI_STATE is the right one.
精彩评论