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

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

级别: 新人
发帖
2
云币
8
在功能模块中开发wifi连接,在点击连接wifi的时候,6.0版本能正常连接,但是在三星7.0版本中点击连接之后不能连接,并且返回为-1 ,请教各路大神,什么原因造成的! h>"j!|#!s  
public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type) vHXCT?FuG  
    { 3eERY[  
        WifiConfiguration config = new WifiConfiguration(); 4l'`q+^-  
        config.allowedAuthAlgorithms.clear(); wl/1~!  
        config.allowedGroupCiphers.clear(); ({0:1*lF@  
        config.allowedKeyManagement.clear(); D"M[}$P  
        config.allowedPairwiseCiphers.clear(); H>]A|-rG#  
        config.allowedProtocols.clear(); I=2b)"t0  
        config.SSID = "\"" + SSID + "\""; > JV$EY,  
N?2C*|%f  
        WifiConfiguration tempConfig = this.IsExsits(SSID); ):lH   
        if(tempConfig != null) { i:60|ngK  
            mWifiManager.removeNetwork(tempConfig.networkId); \:4SN&I~  
        } yJ4ZB/ZQ  
B!1h"K5.($  
        if(Type == 1) //WIFICIPHER_NOPASS Ay0.D FL  
        { ]$i@^3`[w  
            config.wepKeys[0] = ""; 2( U;{;\n*  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); HCw,bRxm  
            config.wepTxKeyIndex = 0; =2@ V}  
        } E NrcIZ  
        if(Type == 2) //WIFICIPHER_WEP "0 $UnR  
        { #z+?t  
            config.hiddenSSID = true; 8.:WMH`  
            config.wepKeys[0]= "\""+Password+"\""; MML=J~1  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); o Vpq*"  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); saTS8p z  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); "hk {"0E  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); G#fF("Ndu`  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); bXSAZW f  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); /gn!="J  
            config.wepTxKeyIndex = 0; qKrxln/T  
        } O(6j:XD  
        if(Type == 3) //WIFICIPHER_WPA <eZ*LK?  
        { M!aJKpf  
            config.preSharedKey = "\""+Password+"\""; m}7Nu  
            config.hiddenSSID = true; Z~].v._YV)  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); 2u$rloc$b  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); &M:o(T  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); bct8~dY  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); q ~^!Ck+#*  
            //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); CeeAw_*@  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); bz}-[W+  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); 7pou(U  
            config.status = WifiConfiguration.Status.ENABLED; H~^)^6)^T  
        } MT7B'hd  
        return config; K:^0*5Y-k  
    } 7WwE] ^M  
AVm+ 1  
public void addNetwork(WifiConfiguration wcg) { T2 S fBs  
        int wcgID = mWifiManager.addNetwork(wcg); i4]oE&G  
        boolean b =  mWifiManager.enableNetwork(wcgID, true); C}(@cn `L  
        Log.e("addNetwork","a--" + wcgID); C$0g2X  
        Log.e("addNetwork","b--" + b); 4v`IAR?&K;  
    }
关键词: android
级别: 新人
发帖
2
云币
8
只看该作者 沙发  发表于: 09-10
回 楼主asshadow的帖子
难道没人遇到过吗?
发表主题 回复主题
« 返回列表上一主题下一主题

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