阿里云
发表主题 回复主题
  • 1179阅读
  • 1回复

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

级别: 新人
发帖
2
云币
8
在功能模块中开发wifi连接,在点击连接wifi的时候,6.0版本能正常连接,但是在三星7.0版本中点击连接之后不能连接,并且返回为-1 ,请教各路大神,什么原因造成的! pe^hOzVv  
public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type) >?Y)evW  
    { EY~b,MIL4  
        WifiConfiguration config = new WifiConfiguration(); ?yAp&Ad  
        config.allowedAuthAlgorithms.clear(); RYhaQ &1i  
        config.allowedGroupCiphers.clear(); 8aDSRfv*  
        config.allowedKeyManagement.clear(); K4T#8K]aZF  
        config.allowedPairwiseCiphers.clear(); b:%z<vo  
        config.allowedProtocols.clear(); -Iq W@|N  
        config.SSID = "\"" + SSID + "\""; n oWjZ  
bx!uHL=  
        WifiConfiguration tempConfig = this.IsExsits(SSID); 2bJqZ,@  
        if(tempConfig != null) { P:~X az\F  
            mWifiManager.removeNetwork(tempConfig.networkId); rw CFt6;v  
        } j[E8C$lW  
'*4>&V.yX  
        if(Type == 1) //WIFICIPHER_NOPASS ,/m@<NyK  
        { 3K{XT),  
            config.wepKeys[0] = ""; \o|5 /N  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); ^Rel-=Z$B  
            config.wepTxKeyIndex = 0; ?(C(9vO  
        } ` u|8WK:  
        if(Type == 2) //WIFICIPHER_WEP ~Onj| w7  
        { l7{]jKJue  
            config.hiddenSSID = true; 8S8^sP  
            config.wepKeys[0]= "\""+Password+"\""; |_<'q h  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); sObH#/l`  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); iTX:*$~I  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); YwbRzY-#F  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); }JP0q  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); [ H~Yg2O  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); a'NxsByG]s  
            config.wepTxKeyIndex = 0; uq/z.m  
        } UxGr+q  
        if(Type == 3) //WIFICIPHER_WPA "-y 2En  
        { L&gC  
            config.preSharedKey = "\""+Password+"\""; >M}\_c=  
            config.hiddenSSID = true; L9lNAiOH  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); 7@[HRr  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); PZT]H?  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); >DFpL$oP  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); Fi7G S;  
            //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); \(4"kY_=  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); /mi9 q  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); ^)JUl!5j]C  
            config.status = WifiConfiguration.Status.ENABLED; 2H,^i,  
        } Lip(r3  
        return config; 4qd =]i  
    } T(GEFnt Y  
\d"uR@$3mG  
public void addNetwork(WifiConfiguration wcg) { xSf&*wLE  
        int wcgID = mWifiManager.addNetwork(wcg); )2nx5 "  
        boolean b =  mWifiManager.enableNetwork(wcgID, true); f1Z  
        Log.e("addNetwork","a--" + wcgID); BzVF!<!  
        Log.e("addNetwork","b--" + b); ^R g=*L  
    }
关键词: android
级别: 新人
发帖
2
云币
8
只看该作者 沙发  发表于: 2018-09-10
回 楼主asshadow的帖子
难道没人遇到过吗?
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
验证问题: 67 - 22 = ?
上一个 下一个