From cdf5110c7f783bec940831abca1fbd048fb03368 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 8 Nov 2018 19:51:38 +0000 Subject: [PATCH] Prevent crash --- app/src/main/java/eu/faircode/email/Helper.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 35454970e7..0f06e8f837 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -21,6 +21,7 @@ package eu.faircode.email; import android.accounts.Account; import android.accounts.AccountManager; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; @@ -38,6 +39,7 @@ import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageView; import android.widget.Spinner; +import android.widget.Toast; import com.android.billingclient.api.BillingClient; import com.google.android.material.bottomnavigation.BottomNavigationView; @@ -100,7 +102,13 @@ public class Helper { builder.setToolbarColor(Helper.resolveColor(context, R.attr.colorPrimary)); CustomTabsIntent customTabsIntent = builder.build(); - customTabsIntent.launchUrl(context, uri); + try { + customTabsIntent.launchUrl(context, uri); + } catch (ActivityNotFoundException ex) { + Toast.makeText(context, context.getString(R.string.title_no_viewer, uri.toString()), Toast.LENGTH_LONG).show(); + } catch (Throwable ex) { + Helper.unexpectedError(context, ex); + } } static Intent getIntentPrivacy() {