[Android] Catch exception in case bitmap fails to parcelize

Geoffrey Métais git at videolan.org
Wed Nov 15 13:39:03 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 15 12:21:58 2017 +0100| [85aac90675cdcab2aa3be8d27601ba8ea44367a4] | committer: Geoffrey Métais

Catch exception in case bitmap fails to parcelize

> https://code.videolan.org/videolan/vlc-android/commit/85aac90675cdcab2aa3be8d27601ba8ea44367a4
---

 .../src/org/videolan/vlc/PlaybackService.java      | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 9fc38efbe..b410643d0 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -2689,21 +2689,22 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
             registerMedialibrary(new Runnable() {
                 @Override
                 public void run() {
-                    VLCApplication.runBackground(new Runnable() {
-                        @Override
-                        public void run() {
-                            result.sendResult(BrowserProvider.browse(parentId));
-                        }
-                    });
+                    sendResults(result, parentId);
                 }
             });
         else
-            VLCApplication.runBackground(new Runnable() {
-                @Override
-                public void run() {
+            sendResults(result, parentId);
+    }
+
+    private void sendResults(@NonNull final MediaBrowserServiceCompat.Result result, @NonNull final String parentId) {
+        VLCApplication.runBackground(new Runnable() {
+            @Override
+            public void run() {
+                try {
                     result.sendResult(BrowserProvider.browse(parentId));
-                }
-            });
+                } catch (RuntimeException ignored) {} //bitmap parcelization can fail
+            }
+        });
     }
 
     private class MedialibraryReceiver extends BroadcastReceiver {



More information about the Android mailing list