--- /dev/null
+\r
+\r
+/**\r
+ * Original method retrieved from:\r
+ * http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.html\r
+ */\r
+package org.openintents.util;\r
+\r
+import java.util.List;\r
+\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.content.pm.PackageManager;\r
+import android.content.pm.ResolveInfo;\r
+\r
+/**\r
+ * \r
+ * @author romainguy\r
+ * @author Peli\r
+ *\r
+ */\r
+public class IntentUtils {\r
+ \r
+ /**\r
+ * Indicates whether the specified action can be used as an intent. This\r
+ * method queries the package manager for installed packages that can\r
+ * respond to the specified intent. If no suitable package is\r
+ * found, this method returns false.\r
+ *\r
+ * @param context The application's environment.\r
+ * @param intent The Intent to check for availability.\r
+ *\r
+ * @return True if an Intent with the specified action can be sent and\r
+ * responded to, false otherwise.\r
+ */\r
+ public static boolean isIntentAvailable(final Context context, final Intent intent) {\r
+ final PackageManager packageManager = context.getPackageManager();\r
+ List<ResolveInfo> list =\r
+ packageManager.queryIntentActivities(intent,\r
+ PackageManager.MATCH_DEFAULT_ONLY);\r
+ return list.size() > 0;\r
+ }\r
+}\r