I am trying to get an icon from a website with the following method. I tried to avoid // problems and decided to use a URL object.
public static Bitmap getBitmapFromURL(URL src) {
try {
URL url = src;
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
I run
Bitmap faviconBitmap = getBitmapFromURL(new URL("http", "www"+url, "/favicon.ico"));
with my url set to: url = imdb.com
but I fail and get the following error:
01-24 20:01:33.702: W/System.err(8678): java.io.IOException: Illegal character in authority at index 22: http:
01-24 20:01:33.702: W/System.err(8678): /favicon.ico
Any suggestions to fix this?
source
share