Does anyone know how I can make a synchronous call via android? I basically do not want to continue any further until I get the response back y/n from the server.
This is the simplest version of the code that I have
URL url = new URL("http://google.com");
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
But it gives me this error because it is created on the main thread.
NetworkOnMainThreadException
Any help is greatly appreciated, thanks