I am using android 2.3.3, i had made an rss reader which was working great, then i integrated the code of that simple rss reader into another activity, just copy pasted it carefully, no errors there.
The problem is when i run the app on my emulator it gives me error connecting exception. Then i figured out by putting toasts after everyline in try block that the problem is at httpconnection.connect(); line.
I have added the permission in the android manifest while my logcat gives a warning of javaio exception:error connecting.
    try {
        HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
        //Toast.makeText(this, "urlconnection passed", Toast.LENGTH_SHORT).show();
        httpURLConnection.setAllowUserInteraction(false);
        httpURLConnection.setInstanceFollowRedirects(true);
        //Toast.makeText(this, "setting response method", Toast.LENGTH_SHORT).show();
        httpURLConnection.setRequestMethod("GET");
        //Toast.makeText(this, "connecting", Toast.LENGTH_SHORT).show();
        httpURLConnection.connect();
        Toast.makeText(this, "on response code", Toast.LENGTH_SHORT).show();
        response = httpURLConnection.getResponseCode();
        //Toast.makeText(this, "response code passed", Toast.LENGTH_SHORT).show();
        if (response == HttpURLConnection.HTTP_OK) {
            //Toast.makeText(this, "OK", Toast.LENGTH_SHORT).show();
            inputStream = httpURLConnection.getInputStream();
        }
    } catch (Exception e) {
        // TODO: handle exception
        throw new IOException("Error connecting");
    }
Here the code which creates the object:
URL url = new URL(UrlString);
URLConnection connection = url.openConnection();
if (!(connection instanceof HttpURLConnection)) 
  throw new IOException("Not a HTTP connection"); 
 
     
    