0
我有一个使用毕加索加载背景图像的BackgroundImageActivity。但是,当我回到家中(在BackgroundImageActivity中调用onStop()时),并进入该活动的另一个实例,该活动应该加载另一个背景图像,但是在开始2秒钟后,它仍然显示前一个BackgroundImageActivity的图像。这是一种缓存吗?如何在Android上清除Picasso加载的图像?
如何清除此图像,以便每当我进入BackgroundImageActivity的新实例时,我都看不到前一个图像?
public class BackgroundImageActivity extends Activity {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initBackground();
}
@Override
protected void onStop() {
super.onStop();
Picasso.invalidate(imageUrl, getApplicationContext());
}
private void initBackground() {
...
}
private void setBg(final String imageUrl, final int bg) {
this.imageUrl = imageUrl;
final RequestCreator picassoRequest = Picasso.load(imageUrl, bg).memoryPolicy(MemoryPolicy.NO_CACHE);
targetReference = new Target() {
@Override
public void onBitmapLoaded(final Bitmap bitmap, final Picasso.LoadedFrom from) {
...
}
@Override
public void onBitmapFailed(final Drawable errorDrawable) {
...
}
@Override
public void onPrepareLoad(final Drawable placeHolderDrawable) {
...
}
};
picassoRequest.placeholder(bg).error(bg).into(targetReference);
}
}
谢谢!