Created
March 20, 2013 14:57
-
-
Save nspo/5205324 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ff4af50a4326956672989b335c21520189b6b49b Mon Sep 17 00:00:00 2001 | |
From: Nicolai Spohrer <[email protected]> | |
Date: Wed, 20 Mar 2013 15:20:31 +0100 | |
Subject: [PATCH 1/2] 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 | |
From 04c75a6fe24d8d13005a0460e86a1099f300ce0e Mon Sep 17 00:00:00 2001 | |
From: Nicolai Spohrer <[email protected]> | |
Date: Wed, 20 Mar 2013 15:53:54 +0100 | |
Subject: [PATCH 2/2] Added imports I forgot | |
--- | |
AppRate/src/com/tjeannin/apprate/AppRate.java | 2 ++ | |
1 file changed, 2 insertions(+) | |
diff --git a/AppRate/src/com/tjeannin/apprate/AppRate.java b/AppRate/src/com/tjeannin/apprate/AppRate.java | |
index 8dcdc21..895d14e 100644 | |
--- a/AppRate/src/com/tjeannin/apprate/AppRate.java | |
+++ b/AppRate/src/com/tjeannin/apprate/AppRate.java | |
@@ -4,6 +4,7 @@ import java.lang.Thread.UncaughtExceptionHandler; | |
import android.app.Activity; | |
import android.app.AlertDialog; | |
+import android.content.ActivityNotFoundException; | |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.content.DialogInterface.OnCancelListener; | |
@@ -17,6 +18,7 @@ import android.content.pm.PackageManager.NameNotFoundException; | |
import android.net.Uri; | |
import android.text.format.DateUtils; | |
import android.util.Log; | |
+import android.widget.Toast; | |
public class AppRate implements android.content.DialogInterface.OnClickListener, OnCancelListener { | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment