我可以使用以下方法添加网络,但如果在和之后添加或失败,code
则无法获取状态。请帮忙!!!authentication
Enable
Network
reconnect
mWifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
removeNetwork();
Boolean isWifiConnected = false;
WifiConfiguration mWifiConf = new WifiConfiguration();
mWifiConf.SSID = "\"" + networkList.get(item_pos).SSID + "\"";
mWifiConf.hiddenSSID = true;
mWifiConf.status = WifiConfiguration.Status.ENABLED;
mWifiConf.priority = 1;
if(addWPA2Network(mWifiConf, etPassword.getText().toString())<0)
{
}
else
{
List<WifiConfiguration> list = mWifiManager.getConfiguredNetworks();
for (WifiConfiguration i : list)
{
if (i.SSID != null && i.SSID.equals("\"" + networkList.get(item_pos).SSID + "\""))
{
mWifiManager.disconnect();
isWifiConnected = mWifiManager.enableNetwork(i.networkId, true);
isWifiConnected = mWifiManager.reconnect();
break;
}
}
}