0

Here's a link where the answer present!

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;
}           
}

He is doing disconnect() before enabling particular SSID every time. I followed the same and it is working fine for me.

But the question is why every time disconnect() needed before enable ?

Pritam
  • 339
  • 3
  • 23

1 Answers1

0

Don't use wifiManager.disconnect(). If needed connect to API 19-25. If you need the highest level 8-8.1 you must use it. You can try this library.
But it has one bug - phone keeps the connection for just 35 seconds and after this, it returns to default wifi access point.

Pritam
  • 339
  • 3
  • 23
Tvester
  • 26
  • 4