evotor / evotor-api-example

9 stars 11 forks source link

Обмен данными с сервером #7

Closed hopyres closed 4 years ago

hopyres commented 4 years ago

Этот код запускался на сотовом телефоне с Android 9, а на терминале Эвотор на строчке c.connect(); уходит сразу на Finally. ` @Override protected void onPostExecute(String content) { contentText = content; }

private String getContent(String path) throws IOException {
  BufferedReader reader = null;
  try {
    URL url = new URL(path);
    HttpsURLConnection c = (HttpsURLConnection)url.openConnection();
    c.setRequestMethod("GET");
    c.setReadTimeout(10000);
    c.connect();
    reader = new BufferedReader(new InputStreamReader(c.getInputStream()));
    StringBuilder buf = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
      buf.append(line + "\n");
    }
    return(buf.toString());
  }
  finally {
    if (reader != null) {
      reader.close();
    }
  }
}`

Где может быть проблема?