admin管理员组文章数量:1620898
我是Android开发的新手,正在尝试使用Android SDK连接到WiFi网络.断开连接的代码工作正常,但重新连接失败.这是我的代码
try {
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\""; // Please note the quotes. String should contain SSID in quotes
conf.wepKeys[0] = password; //WEP password is in hex, we do not need to surround it with quotes.
conf.wepTxKeyIndex = 0;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
WifiManager wifiManager = (WifiManager)ba.applicationContext.getSystemService(Context.WIFI_SERVICE);
wifiManager.addNetwork(conf);
List list = wifiManager.getConfiguredNetworks();
for( WifiConfiguration i : list ) {
if(i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {
wifiManager.disconnect();
wifiManager.enableNetwork(iworkId, true);
wifiManager.reconnect();
break;
}
}
//WiFi Connection success, return true
return true;
} catch (Exception ex) {
throw ex;
}
我将此代码包装在一个用在其他应用程序中的jar文件中.当我调用此方法并尝试使用SSID和密码连接到WEP网络时,我不断收到以下错误消息:
android.system.ErrNoException: recvfrom failed: ETIMEDOUT (Connection timed out).
该错误确实表明某处存在连接超时,但是我无法弄清楚该错误来修复我的代码.我可以在代码中引入任何指针和更改以使其工作?
Paritosh
版权声明:本文标题:android wifi代理 网络连接不上,android-无法连接到WiFi网络 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728817678a1175116.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论