Why couldn't able to get response from a webpage? Android
<p>I'm very new to Java/Android and I have a code to get the response of a webpage. I have a code like this, but for some reason the <code>BufferedReader</code>'s <code>in.readLine()</code> is always returning null.</p>

<pre><code>URL url = new URL(endPoint);
connection = (HttpURLConnection) url.openConnection();

connection.setConnectTimeout(connectionTimeout);
connection.setReadTimeout(readTimeout);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", "" + Integer.toString(encodedParams.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);

// Setup the POST payload
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(encodedParams);
wr.flush();
wr.close();

// Read the response
InputStream inputStream = connection.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
</code></pre>

<p>Not sure where I'm making the mistake.</p>

<p>Thanks in advance.</p>
