Is it possible to disable wireless networking using the Android SDK or NDK?

一笑奈何 提交于 2019-12-01 21:54:40

In order to enable / disable the WiFi state, you have to grant the following permission in the application manifest

android.permission.CHANGE_WIFI_STATE

You can then use the WifiManager to set enable/disable the WIFI.

WifiManager wifiManager = (WifiManager)getBaseContext().getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(enabled);

More info on http://developer.android.com/reference/android/net/wifi/WifiManager.html

For a complete sample, check the following post : http://android-er.blogspot.com/2011/01/turn-wifi-onoff-using.html

Yes you can disable the wifi programmatically:

  1. Retrieve a WifiManager object from Context.getSystemService(Context.WIFI_SERVICE)
  2. Set setWifiEnabled to true or false as you wish

Look up for the permission settings. You will probably need to add some in the AndroidManifest.xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!