My app has 2 buttons, one to create a hotspot, another one to join a hotspot. The flow is :
I create a hotspot on one of the devices and then try to join it with other device (through my app).
The problem is that sometimes i can not join the hotspot if it was created by a Nougat device, it gets stuck on "Obtaining IP Address".
This is the code that i use to join the network :
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;
}
}
The code to create the hotspot is the usual... by reflection with the method setWifiApConfiguration().
Is it an Android bug ? Or it is due to my code?
EDIT : It works on Android 7.0, but doesn't work on Android 7.1.1. I guess it might be a bug, because the hotspot will be created, be won't be marked as active.