You can try loading the icons with HttpClient. Fe :.
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
..........
ArrayList<String> list;
HttpClient httpclient = new DefaultHttpClient();
final int size = list.size();
for (int i = 0; i < size; ++i) {
try {
String pure_url = extractPureUrl(url);
HttpResponse response = httpclient.execute(new HttpGet(pure_url + "/favicon.ico"));
if (response.getEntity() != null) {
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
byte[] image_bytes = out.toByteArray();
bmp = BitmapFactory.decodeStream(new ByteArrayInputStream(image_bytes));
if (bmp != null) {
}
} else {
response.getEntity().consumeContent();
}
}
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
}
private static final String EXTENDED_HTTP_PREFIX = "http://www.";
private static final String HTTP_PREFIX = "http://";
private static String extractPureUrl(String srcUrl) {
String sw = srcUrl.toLowerCase();
String s = sw.startsWith(EXTENDED_HTTP_PREFIX)
? sw.substring(EXTENDED_HTTP_PREFIX.length())
: sw.startsWith(BookmarkInfo.HTTP_PREFIX)
? sw.substring(BookmarkInfo.HTTP_PREFIX.length())
: sw;
int n = s.indexOf('/');
if (n == -1) return srcUrl;
return HTTP_PREFIX + s.substring(0, n);
}
There are potential problems here - iico format is not officially supported by Android . In practice, BitmapFactory decodes the ico format on most devices without any problems. Anyway, I'm not sure if it will decode ico on abs of all devices.
source
share