和android一样,所以没啥可写的~~
添加权限:
1 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 2 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> 3 <uses-permission android:name="android.permission.WAKE_LOCK" />
声明变量:
1 WifiManager wm = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
判断状态:
1 wm.isWifiEnabled()
打开|关闭:
1 wm.setWifiEnabled(true); 2 wm.setWifiEnabled(false);