javaandroidxmllayoutwebview

Any way to grab a logo icon from website URL, programmatically?


I am in the process of creating an activity where I will show the list of website visited with its logo and its alias name chosen by user.

e.g.

The question is, (Ref. attached image) How to get website logo displayed on left side of http://?

Like below I want to just grab the icon and save it locally


Solution

  • It's called a favicon, and all you have to do is:

    1. If there's an icon at /favicon.ico, use that.
    2. Otherwise, get the content of the page, and extract the location from <link rel="shortcut icon" href="URL goes here" />. You’ll need to use an HTML parser and find the <link> with a rel of either icon or shortcut icon.