[Android] [PATCH 4/4] Catch OutOfMemory exception

Geoffrey Métais geoffrey.metais at gmail.com
Thu Apr 2 16:54:47 CEST 2015


Just in case...
---
 vlc-android/src/org/videolan/vlc/util/BitmapUtil.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java b/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java
index c26f41b..67545d8 100644
--- a/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java
+++ b/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java
@@ -131,7 +131,11 @@ public class BitmapUtil {
             options.inJustDecodeBounds = false;
 
             // Decode the file (with memory allocation this time)
-            cover = BitmapFactory.decodeFile(uri, options);
+            try {
+                cover = BitmapFactory.decodeFile(uri, options);
+            } catch (OutOfMemoryError e) {
+                cover = null;
+            }
         }
 
         return cover;
-- 
2.1.0



More information about the Android mailing list