Tuesday, 14 February 2012

Android: exception when downloading web page without network connection


URL url = new URL("http://blah");
InputStream is = null;
is = url.openStream();

When there is no network connection, is is null. Using it will cause null pointer exception.

Check to make sure is is not null before using it.

No comments:

Post a Comment