[Android] Allow VLC to receive shared urls
Geoffrey Métais
git at videolan.org
Wed May 9 19:09:30 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 9 19:09:07 2018 +0200| [584bc2294e38082a869baba3b684a76ee8f5b9c3] | committer: Geoffrey Métais
Allow VLC to receive shared urls
> https://code.videolan.org/videolan/vlc-android/commit/584bc2294e38082a869baba3b684a76ee8f5b9c3
---
vlc-android/AndroidManifest.xml | 5 +++++
vlc-android/src/org/videolan/vlc/StartActivity.java | 17 ++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/vlc-android/AndroidManifest.xml b/vlc-android/AndroidManifest.xml
index 334ea8a18..8c5c1d056 100644
--- a/vlc-android/AndroidManifest.xml
+++ b/vlc-android/AndroidManifest.xml
@@ -411,6 +411,11 @@
<data android:pathPattern=".*\\.xspf" />
<data android:pathPattern=".*\\.XSPF" />
</intent-filter>
+ <intent-filter android:label="Play with VLC">
+ <action android:name="android.intent.action.SEND" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="*/*" />
+ </intent-filter>
<!-- Search -->
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
diff --git a/vlc-android/src/org/videolan/vlc/StartActivity.java b/vlc-android/src/org/videolan/vlc/StartActivity.java
index afe0f833d..cf97b3f16 100644
--- a/vlc-android/src/org/videolan/vlc/StartActivity.java
+++ b/vlc-android/src/org/videolan/vlc/StartActivity.java
@@ -23,8 +23,10 @@
package org.videolan.vlc;
+import android.content.ClipData;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
@@ -53,10 +55,19 @@ public class StartActivity extends FragmentActivity implements StoragePermission
final boolean tv = showTvUi();
final String action = intent != null ? intent.getAction(): null;
- if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null) {
- if (Permissions.checkReadStoragePermission(this, true))
+ if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null
+ && Permissions.checkReadStoragePermission(this, true)) {
startPlaybackFromApp(intent);
- return;
+ return;
+ } else if (Intent.ACTION_SEND.equals(action)) {
+ final ClipData cd = intent.getClipData();
+ final ClipData.Item item = cd != null && cd.getItemCount() > 0 ? cd.getItemAt(0) : null;
+ final String mrl = item != null ? item.getText().toString() : null;
+ if (mrl != null) {
+ MediaUtils.openMediaNoUi(Uri.parse(mrl));
+ finish();
+ return;
+ }
}
// Start application
More information about the Android
mailing list