[Android] Fix NPE with "vlc://..." uris

Geoffrey Métais git at videolan.org
Wed Dec 16 18:27:17 CET 2015


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec 16 18:26:25 2015 +0100| [0ebdca44af0b78bbedf53a8ade9d8125d528577a] | committer: Geoffrey Métais

Fix NPE with "vlc://..." uris

> https://code.videolan.org/videolan/vlc-android/commit/0ebdca44af0b78bbedf53a8ade9d8125d528577a
---

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java  | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 6108069..811af26 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2800,17 +2800,15 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                     }
                 }
             } /* External application */
-            else if (intent.getDataString() != null) {
-                // Plain URI
-                final String location = intent.getDataString();
+            else if (intent.getData() != null) {
+                mUri = intent.getData();
+
                 // Remove VLC prefix if needed
-                if (location.startsWith("vlc://")) {
-                    mUri = AndroidUtil.LocationToUri(location.substring(6));
-                } else {
-                    mUri = intent.getData();
-                    if (mUri.getScheme() == null)
-                        mUri = AndroidUtil.PathToUri(mUri.getPath());
+                if (TextUtils.equals(mUri.getScheme(), "vlc") && mUri.toString().length() > 6) {
+                    mUri = Uri.parse(mUri.toString().substring(6));
                 }
+                if (mUri.getScheme() == null)
+                    mUri = AndroidUtil.PathToUri(mUri.getPath());
             } else {
                 Log.e(TAG, "Couldn't understand the intent");
                 encounteredError();



More information about the Android mailing list