title: Android HttpUrlConnection not working
body: <p>Basically, I'm trying to connect to a web interface through an Android App. </p>
  
  <p>I managed to send commands to the form successfully using HttpClient. However, I want to accomplish this using HttpUrlConnection as recommended here <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html" rel="nofollow">http://android-developers.blogspot.com/2011/09/androids-http-clients.html</a> with the intention of having a faster and more energy efficient connection.</p>
  
  <pre><code>URL url = new URL("http://" + mIpAddress + ":" + mPort + "/command.html");
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setReadTimeout(10000);
  connection.setConnectTimeout(15000);
  connection.setRequestMethod("POST");
  connection.setDoInput(true);
  connection.setDoOutput(true);
  
  OutputStream os = connection.getOutputStream();
  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  writer.write(URLEncoder.encode("parameter=" + value, "UTF-8");
  writer.flush();
  writer.close();
  os.close();
  
  connection.connect();
  </code></pre>
  
  <p>Edit: No exceptions are being thrown since the code is executing just fine, the request is just probably not in the expected format by the server?</p>