如何使用 Picasso 在 android 应用程序中加载 favicon.ico 图标

how to use Picasso to load favicon.ico icon in android app

使用 picasso 从远程 url 加载图像,它工作正常,除非图像是 favicon.ico

是不是毕加索不处理favico类型的文件?

favIconUrl = "http://www.cnn.com/favicon.ico";

  Picasso.with(mContext)
         .load(favIconUrl)
         .into(target);

一个favicon.ico可以是多种文件格式。 PNGGIFJPEG 等 (See here)。 Picasso 进行抓取,但您的目标(ImageView)可能不支持引用的 .ico 文件格式。

追踪过,貌似毕加索没有处理过:

Picasso picasso = new Picasso.Builder(mContext).listener(new Picasso.Listener() {
    @Override
    public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {

         Log.i("onImageLoadFailed(), uri:"+uri+", exception:"+exception);
                                            }
     }).build();

onImageLoadFailed(), uri:https://www.yahoo.com/favicon.ico, exception:java.io.IOException: 解码流失败。