Possible Duplicate:
How to connect to a specific wifi network in android programmatically?
I have been trying out various ways to connect WEP wireless networks using the following links:
How do I connect to a specific Wi-Fi network in Android programmatically?
OR
How to programmatically create and read WEP/EAP WiFi configurations in Android?
I also tried the quotes and no quotes for the password. doesn't come up at all. Also a combination of both the above links too.
This is the last I tried:
networkSSID = bundle.getString("networkName");
networkPass = bundle.getString("networkPassword");
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";
conf.wepKeys[0] = "\"" + networkPass + "\"";
conf.wepTxKeyIndex = 0;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
Toast.makeText(getApplicationContext(), "pass is" + networkPass ,Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "id is" + networkSSID ,Toast.LENGTH_LONG).show();
WifiManager wifiManager = (WifiManager)this.getSystemService(Context.WIFI_SERVICE);
wifiManager.addNetwork(conf);
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
for( WifiConfiguration i : list ) {
if(i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {
wifiManager.disconnect();
wifiManager.enableNetwork(i.networkId, true);
wifiManager.reconnect();
break;
}
}
I am not sure where the issue is - when I connect manually to the same WEP network through the settings I am able to connect it.
It will be great if somebody can give me a correct solution on how to connect it?
Let me know!!
Thanks!