Picasso 未在 android 中从 Web 加载更新的图像

Picasso not loading updated image from Web in android

我在 android 应用程序中使用 Picasso 从网络加载图像 url,但是当我在网络上更新图像时,我看到图像没有更新。

Picasso.with(context).load("http://testServer.com/Images/sponsor.png").into(imageView1);

提前致谢。

Picasso使用了缓存机制,所以同一张图片不会被重新下载两次。

如果您需要绕过此缓存,您可以更改 memory or network 策略来执行此操作。

Picasso 具有内置缓存功能,因此图像会自动缓存。尝试无效。 示例:

Picasso.with(getActivity()).invalidate(file);

尝试下载查询库,请参阅此处https://code.google.com/p/android-query/wiki/ImageLoading

public  void loadImage(ImageView imageView, String image_url,Contextcontext)
{
 try 
  {
    Picasso.with(context)
    .load(image_url)
    .memoryPolicy(MemoryPolicy.NO_CACHE)
    .networkPolicy(NetworkPolicy.NO_CACHE)
    .placeholder(R.drawable.default_image)
    .into(imageView);
  }

  catch(Exception ex)
  {
    ex.toString();
  }

}