[Android] Catch OutOfMemory exception

Geoffrey Métais git at videolan.org
Tue Apr 7 10:45:15 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr  2 16:53:46 2015 +0200| [dae4f8538aab8e5488ae4205e74aac2d8ebf5011] | committer: Geoffrey Métais

Catch OutOfMemory exception

Just in case...

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=dae4f8538aab8e5488ae4205e74aac2d8ebf5011
---

 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;



More information about the Android mailing list