4 * Original method retrieved from:
\r
5 * http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.html
\r
7 package org.openintents.util;
\r
9 import java.util.List;
\r
11 import android.content.Context;
\r
12 import android.content.Intent;
\r
13 import android.content.pm.PackageManager;
\r
14 import android.content.pm.ResolveInfo;
\r
22 public class IntentUtils {
\r
25 * Indicates whether the specified action can be used as an intent. This
\r
26 * method queries the package manager for installed packages that can
\r
27 * respond to the specified intent. If no suitable package is
\r
28 * found, this method returns false.
\r
30 * @param context The application's environment.
\r
31 * @param intent The Intent to check for availability.
\r
33 * @return True if an Intent with the specified action can be sent and
\r
34 * responded to, false otherwise.
\r
36 public static boolean isIntentAvailable(final Context context, final Intent intent) {
\r
37 final PackageManager packageManager = context.getPackageManager();
\r
38 List<ResolveInfo> list =
\r
39 packageManager.queryIntentActivities(intent,
\r
40 PackageManager.MATCH_DEFAULT_ONLY);
\r
41 return list.size() > 0;
\r