Android : Android - ImageLoader won't re-retrieve the image from URL

on Sunday, August 3, 2014


This is the Activity page named PicURL. I want the app to retrieve the image from the URL whenever this Activity Page is called.


The problem is that this activity page will retrieve the image only once (the first time the activity is called.)


For instance, I open this activity I got picture "A" from the URL. Then I overwrite the picture "A" with picture"B". I reopen this activity but I still got picture "A" which it should be picture"B".



public class PicURL extends Activity {

ImageView imageView;

private ImageLoader imageLoader;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pic_url);

imageLoader = ImageLoader.getInstance();
imageView = (ImageView) findViewById(R.id.imageView);


DisplayImageOptions.Builder optionBuilder = new DisplayImageOptions.Builder();
optionBuilder.showImageForEmptyUri(R.drawable.ic_launcher);
optionBuilder.showImageOnFail(R.drawable.ic_launcher);
optionBuilder.cacheInMemory(true);
optionBuilder.cacheOnDisk(true);
DisplayImageOptions options = optionBuilder.build();

ImageLoaderConfiguration.Builder loaderBuilder =
new ImageLoaderConfiguration.Builder(getApplicationContext());

loaderBuilder.defaultDisplayImageOptions(options);
loaderBuilder.diskCacheExtraOptions(400, 400, null);

ImageLoaderConfiguration config = loaderBuilder.build();

if (!imageLoader.isInited()) {
ImageLoader.getInstance().init(config);
} // Checked if ImageLoader has been initialed or not.


String imageUri = "http://abcdef.com/pic1.png"; //Where the app retrieve the image from the link
imageLoader.displayImage(imageUri, imageView);

}


Apologize for my poor English. Thanks for help!


0 comments:

Post a Comment