首页 > 系统 > Android > 正文

android加载大图片时oom问题处理

2019-11-09 17:27:51
字体:
来源:转载
供稿:网友

忘记从哪看来的了,但是感觉挺好用的。

/** *防止加载大图片时 ,oom错误 */ public static Bitmap readBitMap(Context context, int resId) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPReferredConfig = Bitmap.Config.RGB_565; opt.inPurgeable = true; opt.inInputShareable = true; InputStream is = context.getResources().openRawResource(resId); return BitmapFactory.decodeStream(is, null, opt); }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表