Resolves an issue where the Webview.getfavicon () return value is always empty

Source: Internet
Author: User

In WebView, we need to get the Favicon.ico icon for the site, but by default, the Onreceivedicon method in webchromeclient Gets the icon always null;

Webview.getfavicon (); obtained or NULL, this is strange, so

After some Google, found that foreigners have also encountered this problem.

=======================================================

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 II 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 a example online that shows what to access the Favicon. Any hints would is greatly appreciated.


One of the answers solved the problem.

For the WebView icon methods and listeners to work, you need to first open the webicondatabase manually. You would typically does 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 do this, you should start getting Onreceivedicon () callbacks for all WebView in this Activity, and thegetfav Icon () method should also start returning a valid object rather than null whenever icons is available.

Resolves an issue where the Webview.getfavicon () return value is always empty

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.