[Android] Util method to test if an intent is valid

Geoffrey Métais git at videolan.org
Tue Mar 24 11:25:35 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 24 10:53:06 2015 +0100| [78c5e1bb58f9dd3885390d1df1f82aba15d682a5] | committer: Geoffrey Métais

Util method to test if an intent is valid

Useful for Vanilla/TV check

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

 vlc-android/src/org/videolan/vlc/util/Util.java |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index cdd5718..dc35556 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -26,6 +26,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.videolan.libvlc.LibVLC;
@@ -42,6 +43,8 @@ import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
 import android.content.res.TypedArray;
 import android.net.Uri;
 import android.os.Build;
@@ -313,4 +316,10 @@ public class Util {
         File file = new File(path);
         return (file.exists() && file.canWrite());
     }
+
+    public static boolean isCallable(Intent intent) {
+        List<ResolveInfo> list = VLCApplication.getAppContext().getPackageManager().queryIntentActivities(intent,
+            PackageManager.MATCH_DEFAULT_ONLY);
+        return list.size() > 0;
+}
 }



More information about the Android mailing list