wjskeepmaking
wujushan
2018-01-16 02:15

怎么在Android6.0上连接一个无密码wifi

5
  • andorid l
  • wi-fi
  • android

使用网上的一些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)
        }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换