The code pasted below gets an exception on tha line that says...
InputStream in = new
BufferedInputStream(urlConnection.getInputStream());
It's an IO exception that says: java.net.UnknownHostException: www.android.com
I checked and that is a valid url. I got the original code from the
android docs on HttpURLConnection although I had to fix serveral bugs
in the docs code.
Why am I getting this exception?
thanks,
Gary
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.os.Bundle;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
HttpURLConnection urlConnection = null;
try
{
URL url = new URL("http://www.android.com/");
urlConnection = (HttpURLConnection)
url.openConnection();
InputStream in = new
BufferedInputStream(urlConnection.getInputStream());
readStream(in);
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
urlConnection.disconnect();
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en