android 打开wifi不连接,android – WifiManager重新连接返回true但不连接

如果信号足够强,我的应用会创建一个adhoc连接.不幸的是,

Android不允许多个WIFI网络,所以我必须断开当前的网络.当信号变弱时,我想重新连接到前一个.

我将以前连接的SSID存储在SharedPreference中,然后使用以下代码:

for (WifiConfiguration i : list) {

if (i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {

wifiManager.disconnect();

wifiManager.enableNetwork(i.networkId, true);

boolean success = wifiManager.reconnect();

if (!success) {

wifiManager.reassociate();

}

}

}

代码正常,WifiManger.reconnect();返回true但我没有连接到以前的网络.

这是我要重新连接的家庭网络的配置:

ID: 10 SSID: ""WLAN.Tele2.net"" BSSID: null FQDN: null REALM: null PRIO: 0

KeyMgmt: NONE Protocols: WPA RSN

AuthAlgorithms:

PairwiseCiphers: TKIP CCMP

GroupCiphers: WEP40 WEP104 TKIP CCMP

PSK:

Enterprise config:

password NULL

subject_match NULL

engine 0

client_cert NULL

ca_cert NULL

anonymous_identity NULL

phase1 NULL

identity NULL

key_id NULL

engine_id NULL

phase2 NULL

sim_slot_id NULL

eap NULL

IP config:

IP assignment: DHCP

Proxy settings: NONE

autoJoinBSSID=any

triggeredLow: 0 triggeredBad: 0 triggeredNotHigh: 0

ticksLow: 0 ticksBad: 0 ticksNotHigh: 0

triggeredJoin: 0

autoJoinBailedDueToLowRssi: false

autoJoinUseAggressiveJoinAttemptThreshold: 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值