I am still missing library which enables me to connect to any type of secured wifi. So I made this code, but unfortunately due my lack of Java knowledge (actually its Eclipse which gives me headache) I am unable to build it.
I anybody is willing to join the project I would appreciate it.
public void connectToSSID(int tip) {
String networkSSID = txtUser.toString();
String networkPass = txtPass.toString();
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\""; // Please note the quotes. String
// should contain ssid in quotes
tip = Integer.parseInt(txtTip.toString());
switch (tip) {
case 0: // OPEN
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
case 1: // WEP
conf.wepKeys[0] = "\"" + networkPass + "\"";
conf.wepTxKeyIndex = 0;
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
break;
case 2: // WPA
conf.preSharedKey = "\"" + networkPass + "\"";
default:
break;
}
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.addNetwork(conf);
// CONNECT
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 anybody is willing to join the project I would appreciate it.