I'm not connecting to multiple AP's. Let me explain the program flow:
1. I have my phone connected to my Wifi
2. I power up a new ESP that has not been connected to my WiFi so starts it's own AP
3. I click a button in my app that switches the WiFi and connects to the ESP AP WiFi
4. I configure the WiFi for the ESP and via http send the data to the ESP which then reboots and connects to my WiFi. The ESP AP has now gone.
5. The phone reconnects to the original WiFi (as the ESP AP is no longer there).
6. I now send a UDP broadcast message to the ESP so it identifies itself and returns me it's IP address
7. I now communicate with the ESP via HTTP with the IP address returned in step 6.
Step 5 is the problem, the rest works fine. Steps 6 and 7 work fine if I close and restart my app so I know these work.
When the phone reconnects to the original WiFi (which it does without problem) connectivity is available from the phone (other apps such as WhatsApp, internet browsing, ping etc) all work fine. But my app doesn't. It throws an error when I try to use HTTP:
ResponseError. Reason: java.net.SocketException: socket failed: ENONET (Machine is not on the network), Response:
If I put my ESP back into AP mode and reconnect to the ESP AP from my phone (via step 3) I can again communicate correctly with the ESP.
I'm also using UDP in my app and the same error occurs with UDP connectivity after step 5 without restarting the app.
If I close and open my app then it can connect again correctly.
It seems that something related to network connectivity is not being released properly. 
I'm using the OkHttpUtils2 for the HTTP connectivity and Network for UDP connectivity. 
I have my HTTP routines in a class module (shouldn't make a difference) and the HttpJob is local to the sub so shouldn't be holding on to any old configuration:
	
	
	
	
	
	
	
	
	
		Sub FetchWebsite(url As String, param() As String) As ResumableSub
    Private myJob As HttpJob
    Dim data As String
    
    myJob.Initialize("", Me)
    If param.Length = 1 Then
        myJob.Download(url)
    Else
        myJob.Download2(url, param)
    End If
    Wait For (myJob) JobDone (myJob As HttpJob)
    If myJob.Success Then
        data = myJob.GetString
    Else
        data = myJob.ErrorMessage
    End If
    myJob.Release
    Return data
End Sub
	 
	
	
		
	
 
It's called as follows:
	
	
	
	
	
	
	
	
	
		Wait For (FetchWebsite("http://" & Main.httpServer & "/status",Array As String("") )) complete(data As String)
	 
	
	
		
	
 Main.httpServer is the IP address of the ESP