解决webview.getFavicon()返回值总是为空的问题
在webview中,我们需要获取网站的favicon.ico图标,但是默认状态下,WebChromeClient中的onReceivedIcon方法获取到的icon总是为null;
webview.getFavicon();获得到的还是null,这个就奇怪了,于是
经过一番google,发现老外也遇到了这个问题.
=======================================================
http://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon
I'd like to display the favicon of the website I am accessing via the android.webkit.WebView. I've tried two ways to get it:
1) WebViewClient.onPageStarted() method has a favicon parameter that is always null.
2) WebChromeClient.onReceivedIcon() method is never called.
3) Called WebView.getFavicon() in onPageStarted() andonPageFinished() but it always returns null.
I haven't been able to find an example online that shows how to access the favicon. Any hints would be greatly appreciated.
其中有个回答解决了这个问题.
For the WebView icon methods and listeners to work, you need to first open the WebIconDatabase manually. You would typically do this in theonCreate() method of your Activity.
Try adding the following line to onCreate():
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
Once you've done this, you should start getting onReceivedIcon() callbacks for any WebView in this Activity, and thegetFavicon() method should also start returning a valid object rather than null whenever icons are available.
解决webview.getFavicon()返回值总是为空的问题的更多相关文章
- 关于mybatis返回值resultType为空的问题
假设数据库中一个user表 此时只有id为1的数据,当我们查询id为2的年龄时的时候返回值为null 但是在mybatis中预定义UserMapper.xml中 <select id=" ...
- C#进阶系列——WebApi 接口返回值不困惑:返回值类型详解
前言:已经有一个月没写点什么了,感觉心里空落落的.今天再来篇干货,想要学习Webapi的园友们速速动起来,跟着博主一起来学习吧.之前分享过一篇 C#进阶系列——WebApi接口传参不再困惑:传参详解 ...
- WebApi 接口返回值类型详解 ( 转 )
使用过Webapi的园友应该都知道,Webapi的接口返回值主要有四种类型 void无返回值 IHttpActionResult HttpResponseMessage 自定义类型 此篇就围绕这四块分 ...
- WebApi接口返回值不困惑:返回值类型详解
前言:已经有一个月没写点什么了,感觉心里空落落的.今天再来篇干货,想要学习Webapi的园友们速速动起来,跟着博主一起来学习吧.作为程序猿,我们都知道参数和返回值是编程领域不可分割的两大块,此前分享了 ...
- WebApi 接口返回值不困惑:返回值类型详解。IHttpActionResult、void、HttpResponseMessage、自定义类型
首先声明,我还没有这么强大的功底,只是感觉博主写的很好,就做了一个复制,请别因为这个鄙视我,博主网址:http://www.cnblogs.com/landeanfen/p/5501487.html ...
- (转)C# WebApi 接口返回值不困惑:返回值类型详解
原文地址:http://www.cnblogs.com/landeanfen/p/5501487.html 正文 前言:已经有一个月没写点什么了,感觉心里空落落的.今天再来篇干货,想要学习Webapi ...
- HashMap的put方法返回值问题
API文档中的描述: 先看一个例子 Map<Character, Integer> map = new HashMap<Character, Integer>(); Syste ...
- [转]C#进阶系列——WebApi 接口返回值不困惑:返回值类型详解
本文转自:http://www.cnblogs.com/landeanfen/p/5501487.html 阅读目录 一.void无返回值 二.IHttpActionResult 1.Json(T c ...
- Web Api返回值
首先:注明,我还没这么强的功力啦!这是我看的网上的,因为怕博主删除就自己复制了一下 博主的网址是:http://www.cnblogs.com/landeanfen/p/5501487.html 使用 ...
随机推荐
- 支付宝SDK
由于支付宝SDK对于整个支付流程已经介绍的十分详细了,在这里我就简单说一些注意点. 由于存在支付宝可能没有安装的情况,所以我们在调用支付宝支付时,需要对其进行判断,做出不同的处理方式,即是使用客户端支 ...
- 关于 Oracle 11g r2 Enterprise Manager (EM) 在windows环境无法启动的解决办法
正确的解决办法是在安装的时候使用emca正确安装 如果已经安装过Enterprise Manager: 请用是如下命令卸载后重装 emca -deconfig dbcontrol db emca -r ...
- 从0开始搭建SQL Server 2012 AlwaysOn 第三篇(安装数据,配置AlwaysOn)
这一篇是从0开始搭建SQL Server 2012 AlwaysOn 的第三篇,这一篇才真正开始搭建AlwaysOn,前两篇是为搭建AlwaysOn 做准备的 操作步骤: 1.安装SQL server ...
- vue2.0 vue.set()
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 看到了一篇不错的tensorflow文章
http://dataunion.org/28906.html 本文作者 Steven Dufresne,总结了新手学 TensorFlow 需要的核心知识点和实操内容,旨在鼓励更多人借 Tensor ...
- 在Gitlab上怎么添加ssh key
原因分析: 某台centos没有权限克隆gitlab上的git项目,没有权限,报错信息如下 我首先想到的是,在gitlab上没有添加这台centos服务器的秘钥,导致没有权限拉取项目信息 解决步骤: ...
- Lodash数组方法中文总结
LodashAPI总结 Lodash是一个特别特别好用的工具,感觉有了Lodash就没有解决不了的问题了~~~~ 使用初开始 官网 https://www.lodashjs.com/docs/4.17 ...
- CE工具里自带的学习工具--第四关
图解:
- 安装钩子 SetWindowsHookE
SetWindowsHookEx 函数将应用程序定义的钩子安装到一个钩链.要将安装一个钩子来监测系统的某些类型的事件.这些事件是与特定的线程或所有线程中调用线程作为同一桌面相关联. Syntax HH ...
- run loop
Objective-C之run loop详解 作者:wangzz 原文地址:http://blog.csdn.net/wzzvictory/article/details/9237973 转载请注明出 ...