diff --git a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/StandardActivity.java b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/StandardActivity.java index e8bc0959..ac1e6d9f 100644 --- a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/StandardActivity.java +++ b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/activities/StandardActivity.java @@ -11,6 +11,7 @@ import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -141,19 +142,22 @@ public void onDialogNegativeClick(final DialogFragment dialog) { checkUnlockerApp(); // Check in-app purchases - GoogleBillingHelper.initialize(this, new OnInventoryFinishedListener() { - - @Override - public void handleProducts(final List purchases, final List availableProducts, - final boolean isPremium) { - PreferenceUtil.setSharedPreferenceBoolean(R.string.key_internal_has_premium_pack, isPremium); - if (isPremium) { - invalidateOptionsMenu(); + try { + GoogleBillingHelper.initialize(this, new OnInventoryFinishedListener() { + @Override + public void handleProducts(final List purchases, final List availableProducts, + final boolean isPremium) { + PreferenceUtil.setSharedPreferenceBoolean(R.string.key_internal_has_premium_pack, isPremium); + if (isPremium) { + invalidateOptionsMenu(); + } + GoogleBillingHelper.dispose(); } - GoogleBillingHelper.dispose(); - } - }); - + }); + } + catch (Exception e) { + Log.e(Application.TAG, "Failed to call Google Billing Helper", e); + } } } } @@ -230,7 +234,20 @@ else if (itemId == R.id.action_camera) { } else if (itemId == R.id.action_purchase) { DialogUtil.displayToast(this, R.string.message_dialog_triggering_purchase); - triggerDefaultPurchase(); + try { + triggerDefaultPurchase(); + } + catch (Exception e) { + Log.e(Application.TAG, "Failed to call Google Billing Helper", e); + Intent googlePlayIntent = new Intent(Intent.ACTION_VIEW); + googlePlayIntent.setData(Uri.parse("market://details?id=de.jeisfeld.augendiagnoseunlocker")); + try { + startActivity(googlePlayIntent); + } + catch (Exception e1) { + DialogUtil.displayError(this, R.string.message_dialog_failed_to_open_google_play, false); + } + } return true; } else if (itemId == R.id.action_rating) { diff --git a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/fragments/SettingsFragment.java b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/fragments/SettingsFragment.java index 8641b18f..e01cba40 100644 --- a/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/fragments/SettingsFragment.java +++ b/AugendiagnoseIdea/augendiagnoseLib/src/main/java/de/jeisfeld/augendiagnoselib/fragments/SettingsFragment.java @@ -237,7 +237,12 @@ else if (mType.equals(getActivity().getString(R.string.key_dummy_screen_premium_ * Initialize Google Billing (after having permission). */ public final void initializeGoogleBilling() { - GoogleBillingHelper.initialize(getActivity(), mOnInventoryFinishedListener); + try { + GoogleBillingHelper.initialize(getActivity(), mOnInventoryFinishedListener); + } + catch (Exception e) { + android.util.Log.e(Application.TAG, "Failed to call Google Billing Helper", e); + } } /**