diff options
| author | campbeb <bpcampbell@gmail.com> | 2012-03-03 19:02:12 +0900 |
|---|---|---|
| committer | campbeb <bpcampbell@gmail.com> | 2012-03-03 19:02:12 +0900 |
| commit | af4d124d9b0dd81a53df46eb185b3b29a4033228 (patch) | |
| tree | 428b402e46517f2c2dcb840123adb4343218d652 /main/src | |
| parent | 834a683d0f63b119587ab709f6f9ed4230f4dae8 (diff) | |
| download | cgeo-af4d124d9b0dd81a53df46eb185b3b29a4033228.zip cgeo-af4d124d9b0dd81a53df46eb185b3b29a4033228.tar.gz cgeo-af4d124d9b0dd81a53df46eb185b3b29a4033228.tar.bz2 | |
Fix check for calendar add-on installed
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index a341333..7bfab3b 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -796,7 +796,7 @@ public class CacheDetailActivity extends AbstractActivity { private void addToCalendarWithIntent() { - final boolean calendarAddOnAvailable = cgBase.isIntentAvailable(this, ICalendar.INTENT); + final boolean calendarAddOnAvailable = cgBase.isIntentAvailable(this, ICalendar.INTENT, Uri.parse(ICalendar.URI_SCHEME + "://" + ICalendar.URI_HOST)); if (calendarAddOnAvailable) { final Parameters params = new Parameters( 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; |
