I am trying to get a favicon 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 am running
Bitmap faviconBitmap = getBitmapFromURL(new URL("http", "www"+url, "/favicon.ico"));
with my url set to: url = imdb.com
but I am failing and getting the following error:
01-24 20:01:33.702: W/System.err(8678): java.io.IOException: Illegal character in authority at index 22: http://www.nytimes.com
01-24 20:01:33.702: W/System.err(8678): /favicon.ico
any suggestions on how to fix this?
Looks like you have a newline or some other character at the end of url
after "nytimes.com".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With