阿里云
阿里云多端小程序中小企业获客首选
发表主题 回复主题
  • 1945阅读
  • 1回复

[交流乐园]wifi连接 android三星7.0版本WifiManager.addNetwork返回-1

级别: 新人
发帖
2
云币
8
在功能模块中开发wifi连接,在点击连接wifi的时候,6.0版本能正常连接,但是在三星7.0版本中点击连接之后不能连接,并且返回为-1 ,请教各路大神,什么原因造成的! &*##bA"!B  
public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type) aRj9E}  
    { Njxv4cc  
        WifiConfiguration config = new WifiConfiguration(); Z-^LKe  
        config.allowedAuthAlgorithms.clear(); Z/W:97M  
        config.allowedGroupCiphers.clear(); v&9y4\j  
        config.allowedKeyManagement.clear(); P@Hs`=  
        config.allowedPairwiseCiphers.clear(); hpHr\g  
        config.allowedProtocols.clear(); B-xGX$<z  
        config.SSID = "\"" + SSID + "\""; /kE6@  
fa-IhB1!K  
        WifiConfiguration tempConfig = this.IsExsits(SSID); b,5~b&<h  
        if(tempConfig != null) { /$i.0$L  
            mWifiManager.removeNetwork(tempConfig.networkId); 5y d MMb  
        } 0pK=o"^?@  
|9uOUE  
        if(Type == 1) //WIFICIPHER_NOPASS ?Y$JWEPJ  
        { u8'Zl8 g  
            config.wepKeys[0] = ""; |nc@"OJ  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); H['N  
            config.wepTxKeyIndex = 0; p#&h=,W}  
        } y<?kzt  
        if(Type == 2) //WIFICIPHER_WEP Ghu#XJB?  
        { n4s+>|\M  
            config.hiddenSSID = true; cA2V2S)  
            config.wepKeys[0]= "\""+Password+"\""; u7Y WnD  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); `[z<4"Os   
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); SOs:]U-T3  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); #pT"BSz]  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); ed]=\Key  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); {'N Z.  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); p09HL%~R  
            config.wepTxKeyIndex = 0; 68NYIyTW9  
        } $I!XSz"/e  
        if(Type == 3) //WIFICIPHER_WPA ?[VM6- &  
        { 61,;Uc\T  
            config.preSharedKey = "\""+Password+"\""; TcyNIx  
            config.hiddenSSID = true; &Q%zl9g(g  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); rDD:7*z  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); =qoWCmg"&  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); h2)yq:87  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); }v@dL3{f  
            //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); ZEXc%-M  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); S(o#K|)>  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); &)YQvTzs  
            config.status = WifiConfiguration.Status.ENABLED; +s"hqm  
        } _A M*@|p,  
        return config; 9 3U_tQ&1?  
    } P!~MZ+7#&  
5 z~1Dw  
public void addNetwork(WifiConfiguration wcg) { ?# Mr  
        int wcgID = mWifiManager.addNetwork(wcg); jTf@l?|  
        boolean b =  mWifiManager.enableNetwork(wcgID, true); 8J*"%C$qe  
        Log.e("addNetwork","a--" + wcgID); }elc `jj  
        Log.e("addNetwork","b--" + b); &qLf@1AD  
    }
关键词: android
级别: 新人
发帖
2
云币
8
只看该作者 沙发  发表于: 2018-09-10
回 楼主asshadow的帖子
难道没人遇到过吗?
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
验证问题: ECS是阿里云提供的什么服务? 正确答案:云服务器
上一个 下一个
      ×
      全新阿里云开发者社区, 去探索开发者的新世界吧!
      一站式的体验,更多的精彩!
      通过下面领域大门,一起探索新的技术世界吧~ (点击图标进入)