aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/UsefulAppsActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/UsefulAppsActivity.java')
-rw-r--r--main/src/cgeo/geocaching/UsefulAppsActivity.java26
1 files changed, 11 insertions, 15 deletions
diff --git a/main/src/cgeo/geocaching/UsefulAppsActivity.java b/main/src/cgeo/geocaching/UsefulAppsActivity.java
index a2cdaf7..d4517dc 100644
--- a/main/src/cgeo/geocaching/UsefulAppsActivity.java
+++ b/main/src/cgeo/geocaching/UsefulAppsActivity.java
@@ -5,8 +5,10 @@ import butterknife.InjectView;
import cgeo.geocaching.activity.AbstractActionBarActivity;
import cgeo.geocaching.ui.AbstractViewHolder;
+import cgeo.geocaching.utils.ProcessUtils;
+
+import org.eclipse.jdt.annotation.NonNull;
-import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -36,27 +38,16 @@ public class UsefulAppsActivity extends AbstractActionBarActivity {
private final int titleId;
private final int descriptionId;
private final int iconId;
+ @NonNull
private final String packageName;
- public HelperApp(final int title, final int description, final int icon, final String packageName) {
+ public HelperApp(final int title, final int description, final int icon, @NonNull final String packageName) {
this.titleId = title;
this.descriptionId = description;
this.iconId = icon;
this.packageName = packageName;
}
- private void installFromMarket(final Activity activity) {
- try {
- // allow also opening pure http URLs in addition to market packages
- final String url = (packageName.startsWith("http:")) ? packageName : "market://details?id=" + packageName;
- final Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
- activity.startActivity(marketIntent);
-
- } catch (final RuntimeException e) {
- // market not available in standard emulator
- }
- }
}
private static final HelperApp[] HELPER_APPS = {
@@ -106,7 +97,12 @@ public class UsefulAppsActivity extends AbstractActionBarActivity {
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
final HelperApp helperApp = HELPER_APPS[position];
- helperApp.installFromMarket(UsefulAppsActivity.this);
+ if (helperApp.packageName.startsWith("http")) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(helperApp.packageName)));
+ }
+ else {
+ ProcessUtils.openMarket(UsefulAppsActivity.this, helperApp.packageName);
+ }
}
});
}