0

I want to view favicon.ico in the browser but not download them to my computer. How do I enforce that?

punch line

I have an app that is supposed to display favicons given a url. The app is successful only when the favicon.ico would display in browser as opposed to downloading. So I need to somehow force the image to display in browser. For example http://www.nydailynews.com/favicon.ico does not display in browser but rather downloads (chrome browser). But I see that safari is able to force it to display in browser. How can my android app do the same, as safari?

From android I am using picasso to load the images in a ListView

learner
  • 11,490
  • 26
  • 97
  • 169

1 Answers1

0

This is not a solution, but I'm not really sure what you're trying to do. Favicon does load in the WebView, it doesn't download it. I just tried the following code,

WebView view = (WebView) findViewById(R.id.web_view);
view.loadUrl("http://www.google.com/favicon.ico");

And this loads the icon in the WebView. Also I tried opening the same url in my Chrome Android app and it works too. It doesn't download it.
P.S. Note that I'm testing on Motorola Moto X running Android 5.1.

Update

Try this

WebView webView = (WebView) findViewById(R.id.web_view);
String data = "<body>" + "<img src=\"http://www.nydailynews.com/favicon.ico\"/></body>";
webView.loadData(data, "text/html", "utf-8");
Antrromet
  • 15,294
  • 10
  • 60
  • 75
  • Ok, this is strange! The above url doesn't work but Google works, and also my personal website works. Hmm...Thinking... – Antrromet Oct 20 '15 at 07:31
  • That's the very point of my question: some work and some don't. But even the ones that do not work, actually do work in the Safari browser. So Safari must be doing something. And I am wondering if android or picasso can do that same something. But thanks for trying to help, I was sure this question had too many parts to get help (favicon and android is a rare combination). So thanks. – learner Oct 20 '15 at 07:34
  • I am not not using a webview. I am using a ListView with Picasso (see the Picasso hashtag). But perhaps picasso can work this this. Thanks. – learner Oct 20 '15 at 07:50
  • I'm sorry, I missed the `picasso` tag altogether. But when I try the following code, it works for me. `ImageView image = (ImageView) findViewById(R.id.image); Picasso.with(this).load("http://www.nydailynews.com/favicon.ico").into(image);` Am not sure, whats going with your `ListView` then. – Antrromet Oct 20 '15 at 07:56
  • All the ones that load in chrome load for me; the ones that would not load in chrome don't load in my ListView either. I am using galaxy s5. So maybe there is a thing there. – learner Oct 20 '15 at 11:44