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(); 
  • but it gives an error. or an error also does not give? - Saidolim
  • one
    logs are not output because Exception raised, which is caught by the catch() {} block. you will get into this block. There and do what is necessary in the case of a nonexistent server - Vladyslav Matviienko

0