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

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

级别: 新人
发帖
2
云币
8
在功能模块中开发wifi连接,在点击连接wifi的时候,6.0版本能正常连接,但是在三星7.0版本中点击连接之后不能连接,并且返回为-1 ,请教各路大神,什么原因造成的! E`oSi ez)  
public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type) $=\oJ-(!@S  
    { ;y:#S^|?-z  
        WifiConfiguration config = new WifiConfiguration(); H=JP3ID>{  
        config.allowedAuthAlgorithms.clear(); yC9:sQ'k  
        config.allowedGroupCiphers.clear(); h1Ke$#$6  
        config.allowedKeyManagement.clear(); RM?_15m  
        config.allowedPairwiseCiphers.clear(); p[ks} mca@  
        config.allowedProtocols.clear(); )a4E&D  
        config.SSID = "\"" + SSID + "\""; m _t(rn~f6  
pHI%jHHJ  
        WifiConfiguration tempConfig = this.IsExsits(SSID); X+(aQ >y  
        if(tempConfig != null) { Y-}hNZn"{  
            mWifiManager.removeNetwork(tempConfig.networkId); ? RrC~7~  
        } Li?{e+g  
[#H8=  
        if(Type == 1) //WIFICIPHER_NOPASS 'W<a54T?z  
        { = y,yQO  
            config.wepKeys[0] = ""; C%x(`S^/  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); ve64-D  
            config.wepTxKeyIndex = 0; ?z4uze1  
        } l(0&6ENyj  
        if(Type == 2) //WIFICIPHER_WEP 2vW,.]95M  
        { ey9fbS ^I  
            config.hiddenSSID = true; D6pEQdX`  
            config.wepKeys[0]= "\""+Password+"\""; -\sKSY5{R  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); d~Z:$&r  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); IdC k  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); \8C*O{w  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); ^<5^9]x  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); TZ[F u{gZ  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); I5|S8d<  
            config.wepTxKeyIndex = 0; ' /@!"IXz  
        } b`;b}ug  
        if(Type == 3) //WIFICIPHER_WPA .DV#-tUh  
        { $F /p8AraK  
            config.preSharedKey = "\""+Password+"\""; ^5zS2nm  
            config.hiddenSSID = true; cbg3bi  
            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); >P]I&S-.  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); wtgO;w  
            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); D$^7Xhk  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); XTn{1[.O  
            //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); ="[+6X  
            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); { &JurZ  
            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); V.OoZGE>]  
            config.status = WifiConfiguration.Status.ENABLED; 9M-]~.O  
        } S)AE   
        return config; h.+,*9T\  
    } (x*2BEn|  
kY |=a  
public void addNetwork(WifiConfiguration wcg) { B )3SiU  
        int wcgID = mWifiManager.addNetwork(wcg); "N[gMp6U  
        boolean b =  mWifiManager.enableNetwork(wcgID, true); D3 Ea2}8  
        Log.e("addNetwork","a--" + wcgID); CB7R{~ $  
        Log.e("addNetwork","b--" + b); *^$N $t/2  
    }
关键词: android
级别: 新人
发帖
2
云币
8
只看该作者 沙发  发表于: 2018-09-10
回 楼主asshadow的帖子
难道没人遇到过吗?
发表主题 回复主题
« 返回列表上一主题下一主题

限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
验证问题: 40 - 8 = ?
上一个 下一个
      ×
      全新阿里云开发者社区, 去探索开发者的新世界吧!
      一站式的体验,更多的精彩!
      通过下面领域大门,一起探索新的技术世界吧~ (点击图标进入)