解决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 使用 ...
随机推荐
- 7.JAVA-类继承、覆写、final关键字
1.JAVA继承-extends 在java中,要想实现继承则使用extends关键字. 一般子类被称为派生类,父类称为基类(super) extends需要注意的地方: java不允许多重继承(一个 ...
- [BZOJ1025][SCOI2009]游戏 DP+置换群
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1025 题目中的排数就是多少次回到原来的序列.很显然对于题目所描述的任意一种对应法则,其中一 ...
- 锐动SDK置于社区沙龙
北京锐动天地信息技术有限公司成立于2007年9月.多年来一直专注于音视频领域核心技术的研发, 拥有Windows.iOS.Android全平台自主知识产权的领先技术产品. 2011年获得新浪战略投资, ...
- Scala基础篇-02函数与代码块
1.block 代码块也是表达式,其最终求得的值是最后一个表达式的值. {exp1;exp2} { exp1 exp2 } 2.function def funtionName(param:Param ...
- OpenFlow_tutorial_4_Create_a_Learning_Switch
一.环境搭建: 教程里提供的VM image需要梯子才能下载,好不容易下载下来,发现镜像很难用,各种安装问题,搞了好几天也解决不了.后来就自己搭环境,主要是安装Ryu. 1.首先下载相应的python ...
- A C compiler that parses this code will contain at least the following symbol table entries
A C compiler that parses this code will contain at least the following symbol table entries Consider ...
- mfc 菜单
创建一个基于对话框的工程,工程名为CreateMenu 为该对话框增加一个文件菜单项和测试菜单项,如下图所示 测试菜单项至少要有一个子菜单项 在对话框属性中关联该菜单 在resource.h中增加 ...
- mysql 优化策略
from:https://dbaplus.cn/news-155-1531-1.html MySQL逻辑架构 如果能在头脑中构建一幅MySQL各组件之间如何协同工作的架构图,有助于深入理解MySQL服 ...
- babun
Table of Contents 1. 环境 2. 检查/更新 3. 包管理 4. 版本管理 Git 4.1. 设置姓名邮箱(全局方式) 4.2. 添加 SSH 4.3. 链接测试 4.4. 权 ...
- 第2节 mapreduce深入学习:10、手机号码进行分区
需求三:手机号码分区 在需求一的基础上,继续完善,将不同的手机号分到不同的数据文件的当中去,需要自定义分区来实现,这里我们自定义来模拟分区,将以下数字开头的手机号进行分开 135 开头数据到一个分区文 ...