Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nspo/5204959 to your computer and use it in GitHub Desktop.
Save nspo/5204959 to your computer and use it in GitHub Desktop.
From 593ff8b6a854df5cf3695dd571592cca8e204075 Mon Sep 17 00:00:00 2001
From: Nicolai Spohrer <nicolai@xeve.de>
Date: Wed, 20 Mar 2013 15:08:00 +0100
Subject: [PATCH] Fix unhandled ActivityNotFoundException if no Play Store is
installed on device (e.g. emulator)
---
AppRate/src/com/tjeannin/apprate/AppRate.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/AppRate/src/com/tjeannin/apprate/AppRate.java b/AppRate/src/com/tjeannin/apprate/AppRate.java
index c31e5c1..8dcdc21 100644
--- a/AppRate/src/com/tjeannin/apprate/AppRate.java
+++ b/AppRate/src/com/tjeannin/apprate/AppRate.java
@@ -225,7 +225,11 @@ public class AppRate implements android.content.DialogInterface.OnClickListener,
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
- hostActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + hostActivity.getPackageName())));
+ try {
+ hostActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + hostActivity.getPackageName())));
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(hostActivity, "No Play Store installed on device", Toast.LENGTH_SHORT).show();
+ }
editor.putBoolean(PrefsContract.PREF_DONT_SHOW_AGAIN, true);
break;
@@ -264,4 +268,4 @@ public class AppRate implements android.content.DialogInterface.OnClickListener,
}
return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "(unknown)");
}
-}
\ No newline at end of file
+}
--
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment