When requesting a real server, everything works, I can get the response code. How to get at least some answer if the server just does not? Logs in this case are not displayed at all.
new Thread(new Runnable() { @Override public void run() { URL url = null; try { url = new URL(URL); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.connect(); Log.d("MyLog", "Message = " + connection.getResponseMessage()); Log.d("MyLog", "Code = "+connection.getResponseCode()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }).start();
Exceptionraised, which is caught by thecatch() {}block. you will get into this block. There and do what is necessary in the case of a nonexistent server - Vladyslav Matviienko