Aquery - getCachedImage 返回空值



我正在使用Aquery getCachedImage从我的服务器缓存图像url,但我遇到了一些问题。如果我在同一函数中运行它两次并且第一个缓存成功,但第二个缓存将返回 null。当我关闭该页面并再次运行并且都成功时,我想确保每次运行时,它都可以缓存图像,下面是我的代码

boolean memCache = false;
boolean fileCache = true;
Bitmap dealimage = null;
Bitmap dealimage2 = null;
String dealImg = null;
String dealImg2 = null;
try {
JSONArray jsonarray = new JSONArray(imgStr);
for (int i = 0; i < jsonarray.length(); i++) {
    JSONObject jobj = jsonarray.getJSONObject(i);
    dealImg = jobj.getString("IMG1").toString();
    dealimage = aq.getCachedImage(dealImg);
    System.out.println("Image : " + dealimage);
    dealImg2 = jobj.getString("IMG12").toString();
    dealimage2 = aq.getCachedImage(dealImg2);
    System.out.println(" Second Image : " + dealimage2);
    }
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}

结果日志猫

(第一次)图片 : android.graphics.Bitmap@438e79d8小图像:空

(第二次)图片 : android.graphics.Bitmap@42665560小图片 : android.graphics.Bitmap@42891098

我希望两个结果都可以在第一次而不是第二次缓存。为什么第一次无法缓存第二个图像?但是第二次它都能够缓存它?谁能帮忙?

确保从 url 获取图像时允许缓存选项:

boolean memCache = false;
boolean fileCache = true;
aq.id(R.id.image1).image("http://www.vikispot.com/z/images/vikispot/android-w.png", memCache, fileCache);

编号 : http://code.google.com/p/android-query/wiki/ImageLoading

最新更新