The title is pretty self explanatory.
the following code...:
URL imageUrl = new URL(url);
try {
HttpURLConnection conn= (HttpURLConnection)imageUrl.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength();
InputStream is = conn.getInputStream();
return BitmapFactory.decodeStream(is);
} catch (IOException e) {
e.printStackTrace();
}
Will fail if the url does not contain the file format. For example, some images hosted by google will display the image yet not have the file format (.png, .jpg, etc) as part of the url.
As a result, the content-type header of the url connection returns "text/html". I believe this is the issue.
I have tried setting a new content-type header, but that doesnt seem to change anything.
anybody know a workaround?
thanks.