I have an appliation in which I have to download an image from an URL. I am using the following code for the same:
URL url = new URL(address);
URLConnection conn = url.openConnection();
conn.connect();
int length = conn.getContentLength();
is = conn.getInputStream();
bis = new BufferedInputStream(is, length);
bm = BitmapFactory.decodeStream(bis);
The bm which is returned for some reason has height and width -1, and this is throwning Illegal state exception. What could be the reason that height and width is coming -1?