title: HttpURLConnection with JSON on Android 9, API 28
body: <p>I'm trying to use HttpURLConnection in Android 9, API 28. It works on Android 8.0.0, API 26, but not on API 28.</p>
  
  <pre><code>            JSONObject jsonObject = new JSONObject();
              jsonObject.accumulate("name", name);
              String json = jsonObject.toString();
  
              URL url = new URL("http://website_link");
              HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
              urlConnection.setDoOutput(true);
              urlConnection.setRequestMethod("POST");
              urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
  
              OutputStream os = urlConnection.getOutputStream();
              os.write(json.getBytes("UTF-8"));
              os.close();
  
              InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
              BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("utf-8")), 8);
              String line;
              json = "";
  
              while ((line = reader.readLine()) != null) {
                  json += line;
              }
  
              inputStream.close();
  
              jsonObject = new JSONObject(json);
  
              inputStream.close();
              urlConnection.disconnect();
  
              ...
  </code></pre>
  
  <p>I tried to use <code>Log.d</code> to see what code is not executed and I saw that it stops on <code>OutputStream os = urlConnection.getOutputStream();</code></p>
  
  <p>Do you know where is the problem?</p>