TP SINGH
TP SINGH

Reputation: 31

how to get or fetch or download favicon or website icon of any website in android

How to get favicon of any website by entering its URL in android. Or there is any program when we enter the URL the program automatically FATCH its icon and we can use these icon further in android studio in java.

Upvotes: 0

Views: 2270

Answers (1)

Fahad Bin Asif
Fahad Bin Asif

Reputation: 196

This is how you can receive the icon of url in android.

WebView webView = new WebView(getActivity());
webView.loadUrl("https://" + url);

webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            progressBar.setProgress(newProgress);
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            super.onReceivedIcon(view, icon);
            faviconIV.setImageBitmap(icon);
        }
    });

Upvotes: 2

Related Questions