Just call this function by passing the login and password in String more this function works only for Wifi WPA_PSK and Wpa2_psk
public void Connection(String ssid, String password){
WifiConfiguration wfc = new WifiConfiguration();
wfc.SSID = "\"".concat(ssid).concat("\"");
wfc.status = WifiConfiguration.Status.DISABLED;
wfc.priority = 40;
wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
wfc.preSharedKey = "\"".concat(password).concat("\"");
WifiManager wfMgr = (WifiManager) mGap.getSystemService(Context.WIFI_SERVICE);
int networkId = wfMgr.addNetwork(wfc);
if (networkId != -1) {
// success, can call wfMgr.enableNetwork(networkId, true) to connect
wfMgr.enableNetwork(networkId, true);
}
}
Allef, I think this question might help you: http://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically
– Wakim