有两个界面,活动列表和活动详情,点击列表item可跳转到对应活动详情,活动详情点击返回跳到列表,现在活动详情界面的图片显示正常,第一次跳到列表也可以,第二次系统就崩溃了显示内存溢出,怎么解决此问题啊。。。
/** 从缓存中获取图片 **/
public Bitmap getImage(final String url) {
final String path = getDirectory() + "/" + convertUrlToFileName(url);
System.out.println("path:"+path);
File file = new File(path);
if (file.exists()) {
Bitmap bmp = BitmapFactory.decodeFile(path);
if (bmp == null) {
file.delete();
} else {
updateFileTime(path);
return bmp;
}
}
return null;
}
中 Bitmap bmp = BitmapFactory.decodeFile(path);
if (result == null) {
System.out.println("内存中没获取到");
// 文件缓存中获取
result = fileCache.getImage(url);
中 result = fileCache.getImage(url);
if (list.size() >= (1 + arg0)) {
hdbean = list.get(arg0);
carxing.setText(hdbean.getActivityName());
time.setText(hdbean.getSendTime());
// time.setText(hdbean.getValidityTime());
Bitmap b1 = Snippet.getBitmap(URLs.http_head + hdbean.getPicture(),
new ImageCallback() {
public void imageLoaded(Bitmap imageDrawable,
String imageUrl) {
BitmapDrawable s = new BitmapDrawable(imageDrawable);
huodongview.setBackgroundDrawable(s);
}
});
if (b1 != null) {
BitmapDrawable b = new BitmapDrawable();
b =(BitmapDrawable) hdcontext.resizeImage(b1, 150,100);
// BitmapDrawable s = new BitmapDrawable(b1);
huodongview.setBackgroundDrawable(b);
}
}
中 Bitmap b1 = Snippet.getBitmap(URLs.http_head + hdbean.getPicture(),
跪求大神给看看怎么解决。。。
------解决方案--------------------
Bitmap 需要释放资源的
------解决方案--------------------
确实是需要释放资源的,我也是内存溢出,然后从网上各种找,直接搜Android图片内存溢出应该就能有很多结果了,最后不知道怎么弄的,反正就可以了,不释放掉再压缩也没用