diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-11 18:02:09 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-11 18:02:09 +0200 |
commit | db816187f8081fbc58884aadd04ad42443cacdc8 (patch) | |
tree | 6e5cde74fe1bda315ab7bb71526ddbbbdd36ee29 /src/eu/siacs | |
parent | c9a342fc6e9d42fbe7b07a9fd16297ff7b5e1613 (diff) |
check if market is available before starting to install openkey chain
Diffstat (limited to 'src/eu/siacs')
-rw-r--r-- | src/eu/siacs/conversations/ui/XmppActivity.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java index a3503048..4ee51580 100644 --- a/src/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/eu/siacs/conversations/ui/XmppActivity.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.ui; import java.io.FileNotFoundException; import java.lang.ref.WeakReference; +import java.util.List; import java.util.concurrent.RejectedExecutionException; import eu.siacs.conversations.Config; @@ -24,6 +25,8 @@ import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.DialogInterface.OnClickListener; import android.content.IntentSender.SendIntentException; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.Intent; import android.content.ServiceConnection; @@ -153,8 +156,20 @@ public abstract class XmppActivity extends Activity { public void onClick(DialogInterface dialog, int which) { Uri uri = Uri .parse("market://details?id=org.sufficientlysecure.keychain"); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - startActivity(intent); + Intent marketIntent = new Intent(Intent.ACTION_VIEW, + uri); + PackageManager manager = getApplicationContext() + .getPackageManager(); + List<ResolveInfo> infos = manager + .queryIntentActivities(marketIntent, 0); + if (infos.size() > 0) { + startActivity(marketIntent); + } else { + uri = Uri.parse("http://www.openkeychain.org/"); + Intent browserIntent = new Intent( + Intent.ACTION_VIEW, uri); + startActivity(browserIntent); + } finish(); } }); |