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

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

级别: 新人
发帖
2
云币
8
在功能模块中开发wifi连接,在点击连接wifi的时候,6.0版本能正常连接,但是在三星7.0版本中点击连接之后不能连接,并且返回为-1 ,请教各路大神,什么原因造成的! %zN~%mJG  
public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type) p: u@? k  
    { }" STc&1  
        WifiConfiguration config = new WifiConfiguration(); |Y30B,=M  
        config.allowedAuthAlgorithms.clear(); ;pqS|ayl  
        config.allowedGroupCiphers.clear(); zh5ovA%  
        config.allowedKeyManagement.clear(); cvC 7#i[G  
        config.allowedPairwiseCiphers.clear(); G[]h1f!  
        config.allowedProtocols.clear(); 2p~G][  
        config.SSID = "\"" + SSID + "\""; 4$+/7I \  
7>3+]njw  
        WifiConfiguration tempConfig = this.IsExsits(SSID); t\O#5mo  
        if(tempConfig != null) { UYGO|lkEU  
            mWifiManager.removeNetwork(tempConfig.networkId); eC_i]q&o|  
        } 6 )lWuY]e  
X.AE>fx*h  
        if(Type == 1) //WIFICIPHER_NOPASS @&GY5<&b  
        { +*G<xW :M  
            config.wepKeys[0] = ""; 2^)_XVX1  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); s6!! ty;Y  
            config.wepTxKeyIndex = 0; "Mh}n-oju  
        } 2>)::9e4  
        if(Type == 2) //WIFICIPHER_WEP j rg B56LL  
        { s qO$ka{  
            config.hiddenSSID = true; :/6u*HwZh  
            config.wepKeys[0]= "\""+Password+"\""; C#. 27ah  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); "5"{~3Gw^  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); `82^!7!  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); Vg7BK%  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); < fYcON  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); Hi&bNM>?O  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); o),@I#fM  
            config.wepTxKeyIndex = 0; G%T<wKD<  
        } {"_V,HmEF+  
        if(Type == 3) //WIFICIPHER_WPA Dk}txw}#  
        {  /EwNMU*6  
            config.preSharedKey = "\""+Password+"\""; {?X9juc/#  
            config.hiddenSSID = true; {<Xl57w-Q  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); uCj)7>}v{M  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); Fyc":{Jd  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); 3u'@anre  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); 6\x/Z=}L  
            //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); v"dl6%D"  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); F ZN}T{<  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); |al'_s}I  
            config.status = WifiConfiguration.Status.ENABLED; c22L]Sxo  
        } 21hTun"W  
        return config; _ !k\~4U  
    } G4"n`89LK  
Agwl2AM5k  
public void addNetwork(WifiConfiguration wcg) { &_3o1<  
        int wcgID = mWifiManager.addNetwork(wcg); p+Fh9N<F9  
        boolean b =  mWifiManager.enableNetwork(wcgID, true); QPW+L*2  
        Log.e("addNetwork","a--" + wcgID); :-j/Y'H_  
        Log.e("addNetwork","b--" + b); Obc wmL  
    }
关键词: android
级别: 新人
发帖
2
云币
8
只看该作者 沙发  发表于: 09-10
回 楼主asshadow的帖子
难道没人遇到过吗?
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
验证问题: 阿里云官网域名是什么? 正确答案:www.aliyun.com
上一个 下一个