该WebView
component has a getFavicon()
method所以它是绝对有可能解码在Android的ICO文件。你可以have a look at the Android source看看ICO文件是如何解析的。我已经快速浏览过,但找不到相关部分。
或者,您应该使用SDK来获取网页图标。不过,我已经尝试了一下并且无法使其工作。
对于它的价值,这里是我的测试代码,再一次指出,这不起作用:
String url = "http://stackoverflow.com";
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
Log.i("HelloAndroid","Loaded " + url);
Log.i("HelloAndroid","Icon " + (view.getFavicon() == null ? "not" : "") + " found");
}
});
WebIconDatabase wid = WebIconDatabase.getInstance();
wid.requestIconForPageUrl(url, new WebIconDatabase.IconListener() {
public void onReceivedIcon(String url, Bitmap icon) {
Log.i("HelloAndroid","Found Icon for " + url);
}
});
wv.loadUrl("http://stackoverflow.com");
Log.i("HelloAndroid","Loading " + url);
的问题可能会下降的事实,我不加入WebView
到可见View
。如果你确实得到这个工作,我会有兴趣听到你做了什么。
所以很抱歉给出两个半完整的答案,但我认为值得发布我发现的内容。
谢谢。这也是我的想法。但后来我看到了WebView界面,所以我想我会试试看。 – 2010-04-22 14:41:37