使用网上的一些demo,连接总是会失败,比如下面两段代码都会失败:
val config = WifiConfiguration()
config.allowedAuthAlgorithms.clear()
config.allowedGroupCiphers.clear()
config.allowedKeyManagement.clear()
config.allowedPairwiseCiphers.clear()
config.allowedProtocols.clear()
config.SSID = "\"" + SSID + "\""
val tmpConfig = isExsits(ssid)
if (tmpConfig != null) {
mWifiManager.removeNetwork(tmpConfig.networkId)
}
if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
//Password为空字符
config.wepKeys[0] = "\"" + Password + "\""
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE)
config.wepTxKeyIndex = 0
}
val config = WifiConfiguration()
config.allowedAuthAlgorithms.clear()
config.allowedGroupCiphers.clear()
config.allowedKeyManagement.clear()
config.allowedPairwiseCiphers.clear()
config.allowedProtocols.clear()
config.SSID = "\"" + SSID + "\""
val tmpConfig = isExsits(ssid)
if (tmpConfig != null) {
mWifiManager.removeNetwork(tmpConfig.networkId)
}
if (Type == WifiCipherType.WIFICIPHER_NOPASS) {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE)
}