I did research, but i cannot find solution to my problem here, actually i don't know what I am doing wrong but enableNetwork always is returning true and even reconnect() method always return true which is weird, even when wrong password is passed.. can you please point me to right direction? I just want to check wifi connection for specific password. Is this right way to do it?
WifiConfiguration conf = new WifiConfiguration();
conf.preSharedKey = "\""+ networkPass +"\"";
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
int res = wifi.addNetwork(conf);
wifiManager.disconnect();
boolean b = wifiManager.enableNetwork(res, true);
String str = String.valueOf(b);
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_LONG).show();
if (wifiManager.reconnect()) {
Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Not Connected", Toast.LENGTH_LONG).show();
}