开发者

Turning on/off network settings on Android

开发者 https://www.devze.com 2022-12-31 21:08 出处:网络
Is there a (simple) possibility for turning the mobile network on/off with Java code? If so, for mobile service too?

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

精彩评论

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

关注公众号