aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/ProcessUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/utils/ProcessUtils.java')
-rw-r--r--main/src/cgeo/geocaching/utils/ProcessUtils.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/ProcessUtils.java b/main/src/cgeo/geocaching/utils/ProcessUtils.java
new file mode 100644
index 0000000..53991fb
--- /dev/null
+++ b/main/src/cgeo/geocaching/utils/ProcessUtils.java
@@ -0,0 +1,27 @@
+package cgeo.geocaching.utils;
+
+import cgeo.geocaching.cgeoapplication;
+
+import android.content.Intent;
+import android.content.pm.PackageManager;
+
+public class ProcessUtils {
+
+ public static boolean isInstalled(final String packageName) {
+ return getLaunchIntent(packageName) != null;
+ }
+
+ public static Intent getLaunchIntent(final String packageName) {
+ if (packageName == null) {
+ return null;
+ }
+ final PackageManager packageManager = cgeoapplication.getInstance().getPackageManager();
+ try {
+ // This can throw an exception where the exception type is only defined on API Level > 3
+ // therefore surround with try-catch
+ return packageManager.getLaunchIntentForPackage(packageName);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}