Im trying to get the 32px favicon.ico of the websites, but the response it obtain is the 16px favicon, I guess because I´m trying to obtain it by the smarthphone, but I try to change the user agent of the http petition with no result here is my code:
DefaultHttpClient client = new DefaultHttpClient();
String baseUrl = getBaseUrl(url);
HttpGet httpGet = new HttpGet(baseUrl + "/favicon.ico");
httpGet.setHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19");
HttpResponse httpResponse = null;
try {
httpResponse = client.execute(httpGet);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}catch (NullPointerException e) {
e.printStackTrace();
}
InputStream is = null;
try {
is = (java.io.InputStream) httpResponse.getEntity().getContent();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
Drawable favicon = Drawable.createFromStream(is, "src");
final BitmapDrawable bd = (BitmapDrawable) favicon;
Any idea how to get it? Thanks
A
.ico
file can contain several pictures. Therefore, thefavicon.ico
file you get may well contain a 16x16 picture and a 32x32 picture.You can use the
icotool
command line tool to analyze a.ico
file:On Windows, when you open a
.ico
file with the default viewer (just double-click the file), the viewer let you navigate through the multiple pictures contained in the file. It does not print their resolution, but at least you have a clue about what is going on with your strange behavior.Smart phone can't effect that.Actually on some website favicon size 16px and other have 32px. Like facebook,google,twitter have 16px favicon And yahoo,google plus have 32 px favicon...