code: public static boolean checkServerConnection(URL u) {
          boolean value = false;
          try {
              value = new RetrieveCheckServerConnection().execute(u).get();
          } catch (InterruptedException e) {
              e.printStackTrace();
          } catch (ExecutionException e) {
              e.printStackTrace();
          }
          return value;
  
      }
docs: Check if can connect to the server, also this method will need the
  permissions "android.permission.INTERNET"
  
  @param u - server url
  @return true if the connection returned a successful code