我试图获取网站的 32px favicon.ico,但它获得的响应是 16px 的 favicon,我想是因为我试图通过智能手机获取它,但我尝试更改 http 请愿的用户代理这里没有结果是我的代码:
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;
知道如何得到它吗?谢谢