是用两个方法从网络上读取bitmap展示
1. BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inTempStorage = new byte[12 * 1024];
bitmap = BitmapFactory.decodeStream(bis, null, opts);
2. BufferedInputStream bis = null;
ByteArrayOutputStream out = new ByteArrayOutputStream();
bis = new BufferedInputStream(is, BUFFER_SIZE);
int i = -1;
byte buf[] = new byte[4 * 1024];
while ((i = bis.read(buf)) != -1) {
out.write(buf, 0, i);
}
byte imgData[] = out.toByteArray();
bitmap = BitmapFactory.decodeByteArray(imgData, 0,
imgData.length);
很明显的前者OOM的概率几倍于后者。
还请达人给解疑答惑,谢谢!