Catch OutOfMemoryError when decoding bitmaps
@@ -5,9 +5,13 @@ import android.graphics.BitmapFactory;
public class BitmapUtils {
public static Bitmap bitmapFromBytes(byte[] b) {
+ try {
if (b == null) {
return null;
}
return BitmapFactory.decodeByteArray(b, 0, b.length);
+ } catch (OutOfMemoryError e) {
+ return null;
+ }
}
}
