阿里云
1024开发者盛宴之Java专家问答专场
发表主题 回复主题
  • 933阅读
  • 1回复

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

级别: 新人
发帖
2
云币
8
在功能模块中开发wifi连接,在点击连接wifi的时候,6.0版本能正常连接,但是在三星7.0版本中点击连接之后不能连接,并且返回为-1 ,请教各路大神,什么原因造成的! K9=_}lS@'  
public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type) Xqk$[ peS  
    { DS fKUx&  
        WifiConfiguration config = new WifiConfiguration(); B^{DCHu/  
        config.allowedAuthAlgorithms.clear(); +FR"Gt$g  
        config.allowedGroupCiphers.clear(); Mtr~d  
        config.allowedKeyManagement.clear(); 19_F\32  
        config.allowedPairwiseCiphers.clear();  CgWj9 [  
        config.allowedProtocols.clear(); *?K=;$  
        config.SSID = "\"" + SSID + "\""; )d~Mag+  
57r)&8  
        WifiConfiguration tempConfig = this.IsExsits(SSID); 2_Qzc&"[ 4  
        if(tempConfig != null) { {T9g\F*  
            mWifiManager.removeNetwork(tempConfig.networkId); P?F:x=@'|  
        } -uZ^UG!K  
6dh PqL  
        if(Type == 1) //WIFICIPHER_NOPASS `}bUf epMJ  
        { 2%I:s6r  
            config.wepKeys[0] = ""; }|d:(*  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); zV]0S o  
            config.wepTxKeyIndex = 0; :Z)s'd.  
        } fiZ8s=J  
        if(Type == 2) //WIFICIPHER_WEP <}=D?bXw  
        { 2-~oNJqX  
            config.hiddenSSID = true; DuWP)#kg  
            config.wepKeys[0]= "\""+Password+"\"";  ;"3Mm$  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); ! 9e>J  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); qz:OnQv!  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); <j>@Fg#q  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); ">o/\sXeH  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); I'gnw~  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); Z6=!}a%  
            config.wepTxKeyIndex = 0; ,ZSuo4  
        } OKP?^%kD  
        if(Type == 3) //WIFICIPHER_WPA 8|l Yf%n>j  
        { L81"W`?  
            config.preSharedKey = "\""+Password+"\""; .q=X58tHu  
            config.hiddenSSID = true; #O~Y[''C5X  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); I4*N  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); ^~0 r+w61  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); @6E[K'5c1  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); ]8^2(^3ct  
            //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); ; ^$RG  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); @.0,k a,X  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); #wo_  
            config.status = WifiConfiguration.Status.ENABLED; Kq*^*vWC  
        } 'fB`e]_  
        return config; yF:fxdpw  
    } 4 qnQF]4  
#\jPBLc  
public void addNetwork(WifiConfiguration wcg) { _w26iCnB{  
        int wcgID = mWifiManager.addNetwork(wcg); ,To ED  
        boolean b =  mWifiManager.enableNetwork(wcgID, true); k91Y"_&  
        Log.e("addNetwork","a--" + wcgID); kSDV#8 uZ  
        Log.e("addNetwork","b--" + b); aV ^2  
    }
关键词: android
级别: 新人
发帖
2
云币
8
只看该作者 沙发  发表于: 09-10
回 楼主asshadow的帖子
难道没人遇到过吗?
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
批量上传需要先选择文件,再选择上传
 
验证问题: ECS是阿里云提供的什么服务? 正确答案:云服务器
上一个 下一个