解决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 使用 ...
随机推荐
- sql语句添加一列标示,然后进行分页。
,) , sum(Score) as Score ,Student_NO,Student_Name into #a2_tab from ksy_stu_ScoreInfo GROUP BY Stude ...
- UWP Windows10开发更新磁贴和动态更新磁贴
下面将介绍两种方式如何在windows10 uwp开发中如何更新应用磁贴: 实际上windows的磁贴就是用xml实现的,你只需要创建相应格式的xml就可以实现动态磁贴了 一,手动更新磁贴 二,轮询更 ...
- [BZOJ1046][HAOI2007]上升序列 DP+贪心
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1046 我们先求出对于每一个数字作为开头的LCS的长度f[i],最长的f[i]为mxlen. ...
- iOS Programming Subclassing UITableViewCell
iOS Programming Subclassing UITableViewCell 1.Creating BNRItemCell UITableViewCell is a UIView subc ...
- debian设置英文模式
Ubuntu太臃肿了,遂换回debian系统.在虚拟机上装debian,发现console下中文不显示. 各种export方法试过,始终无效.废了一个小时终于找到方法了.记录之. debian设置语言 ...
- vue框架的知识
基础:实例----组件----指令----选项-----计算属性----事件绑定----模板渲染-----内置动画 ---组件交互----路由. vuejs干了什么事情:数据渲染/数据同步 组件化/模 ...
- https://quotefancy.com/ 经典句子(英语) 真是特别好~
https://quotefancy.com/ 经典句子(英语)
- fast rcnn,faster rcnn使用cudann加速问题
之前在fast rcnn,faster rcnn编译过程中USE_CUDNN := 1这一项一直是注释掉的(即不使用cudnn加速),编译会报错: 之所以会这样,是因为fast rcnn,faster ...
- jquery 应用
http://www.jq22.com/ gwj6396668@163.com
- vue props传值方法
<template> <div class="hello"> <ul> <li v-for="(item, index) in ...