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