`
张玉龙
  • 浏览: 737172 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

WifiManager mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);

 
阅读更多
 WifiManager mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
		 
		 
		 List<WifiConfiguration> mWifiConfigurations = mWifiManager.getConfiguredNetworks();
		 for (WifiConfiguration mWifiConfiguration : mWifiConfigurations) {
				if (mWifiConfiguration.SSID.equals("\"free\"")) {
					int indexSSID = mWifiManager.addNetwork(mWifiConfiguration);
					boolean  isConnected = mWifiManager.enableNetwork(mWifiManager.getConfiguredNetworks().get(indexSSID).networkId, false);
					if(isConnected){
						 
					 }
				}
	        }

分享到:
评论

相关推荐

    android 更改 Wifi 或GPS状态

    WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE); 然后,我们可以使用 wifiManager.isWifiEnabled() 方法来获取当前 Wi-Fi 的状态: boolean wifiEnabled = wifiManager....

    wifi.rar_WiFi Application_wifi

    - 获取`WifiManager`实例:`WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);` - 创建`WifiConfiguration`对象,包含SSID(网络名)和预共享密钥(密码)。 - 调用`addNetwork...

    Android开发入门_WiFi_代码.pdf

    WifiManager wifiManager = (WifiManager) Context.getSystemService(Context.WIFI_SERVICE); ``` 你可以使用`WifiManager`提供的方法来控制WIFI的开关,如: - 打开WIFI:`wifiManager.setWifiEnabled(true);` - ...

    AndroidWiFi.rar_android_androidwifi_ppt for android

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); ``` 然后,我们可以通过`wifiManager`来查询Wi-Fi的状态,例如是否开启: ```java boolean isWifiEnabled = wifiManager....

    RSSI.rar_WiFi+RSSI_bean6qq_java获取rssi_site:www.pudn.com_wifi rss

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int rssi = wifiInfo.getRssi(); ``` 3. **显示接入WiFi网络信息**...

    android_rssi.rar_Android WIFI RSSI_WIFI-RSSI_wifi ap_wifi信号_安卓 r

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); // 检查Wi-Fi是否开启 if (wifiManager.isWifiEnabled()) { // 获取Wi-Fi扫描结果 List&lt;ScanResult&gt; scanResults = ...

    Android获取更改gps和WIFI状态.doc

    WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE); wifiManager.isWifiEnabled(); 这需要权限:android.permission.ACCESS_WIFI_STATE 2. 通过 Settings.System 进行操作 ...

    Android 连接Wifi和创建Wifi热点的实例

    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiManager.disconnect(); // 断开现有连接 wifiManager.addNetwork(wifiConfig); // 添加新网络配置 int network...

    Android中wifi检测

    开发者可以通过调用`getSystemService()`方法并传入`Context.WIFI_SERVICE`来获取到`WifiManager`的实例。例如: ```java WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); ``` ...

    android wifi direct代码开启

    WifiP2pManager manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); manager.discoverPeers(channel, new WifiP2pManager.ActionListener() { @Override public void onSuccess() { // ...

    demo_apn2.zip_DEMO_android移动数据

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); boolean isWifiEnabled = wifiManager.isWifiEnabled(); if (isWifiEnabled) { wifiManager.setWifiEnabled(false); } else { ...

    安卓获取wifi强度

    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int rssi = wifiInfo.getRssi(); // 在这里处理rssi值,...

    android_wifi_status

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); String ssid = wifiManager.getConnectionInfo().getSSID(); ``` 在"mgao_wifi_status"这个项目中,很可能包含了一个实现...

    Android实现WIFI连接源码

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); ``` 然后,你可以查询当前的Wi-Fi状态: ```java int wifiState = wifiManager.getWifiState(); switch (wifiState) { case ...

    电视盒子开机自启动wifi热点功能代码,貌似路由器都能省了

    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); Method method = wifiManager.getClass().getMethod("getWifiApState"); int state = (Integer) method.invoke(wifiManager); if(state=...

    android 获取wifi输入密码连接

    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); // 获取当前连接的WiFi信息 WifiInfo wifiInfo = wifiManager.getConnectionInfo(); String currentSSID = wifiInfo....

    【eoeAndroid特刊】第六期 数据通信-成为Android数据流大师

    mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); } } ``` **10.2 连接AP** 连接到接入点(AP)的过程。 **示例代码:** ```java import android.net.wifi.WifiConfiguration; ...

    android 获取mac地址源码

    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); String macAddress = wifiManager.getConnectionInfo().getMacAddress(); ``` 2. **Android 6.0 (API级别23)及以上版本...

    Android获取、设置Wifi状态.pdf

    WifiManager mWiFiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); ``` 这里的关键点在于调用`getSystemService()`方法,并传入`Context.WIFI_SERVICE`作为参数。`Context.WIFI_SERVICE`是...

    Android-Wifi获取刷新

    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); ``` 现在,我们可以通过`WifiManager`来获取Wi-Fi的状态信息。要获取当前连接的SSID(网络标识符),可以调用: ```...

Global site tag (gtag.js) - Google Analytics