开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜