title: Android application internet connection
body: <p>I'm new to Android and this is my first application. I'm to connect internet and download JSON from my companies server but unable to get input stream please check this code and provide me assistance.</p>
  
  <pre><code>URL url = new URL("http://www.android.com/");
  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  urlConnection.connect();
  InputStream in = new BufferedInputStream(urlConnection.getInputStream());
  </code></pre>
  
  <p>URL is not the issue I have tested many URL's. In this code last line gives error. I uses open connectivity (No proxy only firewall) on my development machine and emulators browser is able to access internet.</p>
  
  <p>I have already added </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  </code></pre>
  
  <p>parallel to uses-sdk tag in Manifest file.</p>