I'm new at Android development. I'm making a small app just to understand how the SDK is. One of the task is connect to the internet and download a file. I've been searching here and lots of sites in google and i don't know what's my problem.
This is my code:
- Code: Select all
try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();
response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
but it allways say: IOException: error connecting.
I'm not connecting to localhost (in case this would be a problem), and I'm using android sdk 1.0 rc2 over Windows with Eclipse and ADT 0.8.
Thanks for your help and sorry if this post is repeated but i can't understand why it isn't connecting even searching for similar problems.
PS: I've used code that was a solution for a similar problem but in my case, it doesn't work.


