[Android] Don't set Uri as Intent data on Android 7+

Geoffrey Métais git at videolan.org
Wed Nov 23 15:20:43 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 23 15:16:25 2016 +0100| [e792c2a7e1b50fd875855269352d9182133736c1] | committer: Geoffrey Métais

Don't set Uri as Intent data on Android 7+

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

 libvlc/src/org/videolan/libvlc/util/AndroidUtil.java                | 4 ++++
 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
index a8d046c..232fcd1 100644
--- a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
+++ b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
@@ -67,6 +67,10 @@ public class AndroidUtil {
         return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
     }
 
+    public static boolean isNougatOrLater() {
+        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
+    }
+
     public static File UriToFile(Uri uri) {
         return new File(uri.getPath().replaceFirst("file://", ""));
     }
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 5bf32b5..c9bf947 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -159,6 +159,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     public final static String ACTION_RESULT = Strings.buildPkgString("player.result");
     public final static String EXTRA_POSITION = "extra_position";
     public final static String EXTRA_DURATION = "extra_duration";
+    public final static String EXTRA_URI = "extra_uri";
     public final static int RESULT_CONNECTION_FAILED = RESULT_FIRST_USER + 1;
     public final static int RESULT_PLAYBACK_ERROR = RESULT_FIRST_USER + 2;
     public final static int RESULT_HARDWARE_ACCELERATION_ERROR = RESULT_FIRST_USER + 3;
@@ -1046,7 +1047,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             return;
         Intent resultIntent = new Intent(ACTION_RESULT);
         if (mUri != null && mService != null) {
-            resultIntent.setData(mUri);
+            if (AndroidUtil.isNougatOrLater())
+                resultIntent.putExtra(EXTRA_URI, mUri.toString());
+            else
+                resultIntent.setData(mUri);
             resultIntent.putExtra(EXTRA_POSITION, mService.getTime());
             resultIntent.putExtra(EXTRA_DURATION, mService.getLength());
         }



More information about the Android mailing list