diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2012-03-03 02:39:57 -0800 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-03-03 02:39:57 -0800 |
| commit | a03b45c81af0e3a66eb861f92f243f340823aecd (patch) | |
| tree | ecb19e6d71b1a565ad47a76ab97f9ebfeceadaa2 /main | |
| parent | 3ab8a73408ff7bff9c5ab4787f23167b4b8f2ae6 (diff) | |
| parent | af4d124d9b0dd81a53df46eb185b3b29a4033228 (diff) | |
| download | cgeo-a03b45c81af0e3a66eb861f92f243f340823aecd.zip cgeo-a03b45c81af0e3a66eb861f92f243f340823aecd.tar.gz cgeo-a03b45c81af0e3a66eb861f92f243f340823aecd.tar.bz2 | |
Merge pull request #1220 from campbeb/fixcalendarcall
Fix check for calendar add-on installed
Diffstat (limited to 'main')
| -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 f78c65a..103634e 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 77d0d78..5b4e867 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -2837,8 +2837,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; |
