Android Ion Cache Refresh

时间:2014-11-09 18:09:35

标签: android caching ion

我正在使用特定网址在线获取图片,但网址本身会每隔几分钟自动更改一次。 我正在使用来自Here的ION库 我遇到的问题是当我刷新页面时,页面本身看起来很清爽但是出现了完全相同的图片。 我假设它是一个缓存的图像?如果我重新安装应用程序,它会再次获得正确的图像。

这就是我使用ION的方式,其中imageID2 [position]只是jpg的典型网址。

    Ion.with(imageView)
            .placeholder(R.drawable.ic_launcher)
            .error(R.drawable.ic_launcher)
            .load(imageId2[position]);

无论如何,我可以禁用缓存还是让它再次重新显示图像?

3 个答案:

答案 0 :(得分:6)

使用.noCache()绕过缓存。

答案 1 :(得分:6)

根据文档here,使用" long"构建ImageView请求的方法,以便您可以添加标题,noCache等。

更改原始请求:

Ion.with(imageView)
        .placeholder(R.drawable.ic_launcher)
        .error(R.drawable.ic_launcher)
        .load(urlString);

对此:

Ion.with(context)
        .load(urlString)
        .noCache()
        .withBitmap()
        .placeholder(R.drawable.ic_launcher)
        .error(R.drawable.ic_launcher)
        .intoImageView(imageView);

答案 2 :(得分:3)

您可以在网址中附加一个唯一的字符串,例如当前时间戳,以强制Ion将每个请求视为唯一。