aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/cgBase.java')
-rw-r--r--main/src/cgeo/geocaching/cgBase.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index 8d00710..69125d1 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -2841,8 +2841,33 @@ public class cgBase {
* responded to, false otherwise.
*/
public static boolean isIntentAvailable(Context context, String action) {
+ return isIntentAvailable(context, action, null);
+ }
+
+ /**
+ * Indicates whether the specified action can be used as an intent. This
+ * method queries the package manager for installed packages that can
+ * respond to an intent with the specified action. If no suitable package is
+ * found, this method returns false.
+ *
+ * @param context
+ * The application's environment.
+ * @param action
+ * The Intent action to check for availability.
+ * @param uri
+ * The Intent URI to check for availability.
+ *
+ * @return True if an Intent with the specified action can be sent and
+ * responded to, false otherwise.
+ */
+ public static boolean isIntentAvailable(Context context, String action, Uri uri) {
final PackageManager packageManager = context.getPackageManager();
- final Intent intent = new Intent(action);
+ final Intent intent;
+ if (uri == null) {
+ intent = new Intent(action);
+ } else {
+ intent = new Intent(action, uri);
+ }
List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;