I have a Wifi Micro controller ESP8266 which also has an access point. I have referred to other blogs which talk about programmatically connecting to an access point and tried both the way
Using the exposed standard APIS
wifiManager.enableNetwork(netId, true); wifiManager.saveConfiguration(); wifiManager.reconnect();
Using the APIs which have @ hide on them
wifiManager.connect(netId, ActionListener)
The problem I am facing is that some time after i connect to the access point its getting disconnected from the esp8266 access point and connecting back to my router in both the above mentioned methods.
If i connected via the top bar or through the settings app its connecting in a stable way and never disconnects and I even get the notification
Wi-Fi has no internet access
I don't get the no internet access notification when i connect programmatically. How is the settings app able to connect to the access point in a stable way while my App is not able to.
I am running Androidn 6.0.1 API 23
If you specifically request using that
Networkonce before it disconnects, it will stay connected indefinitely:ConnectivityManager.bindProcessToNetwork(Network)Network.bindSocket(Socket)Network.openConnection(URL)Also see my answer on how to synchronize the timing between network connection and access: https://stackoverflow.com/a/52304308/4969370