From 6b370ca2519512d8d57fd6414336396dae7170b1 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Mon, 30 Nov 2020 19:01:03 +0900 Subject: [PATCH] Handle ActivityNotFoundException while opening URL. Fixes https://github.com/austinhuang0131/barinsta/issues/351 --- app/src/main/java/awais/instagrabber/utils/Utils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index 83dbdac4..e3982f86 100755 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -1,6 +1,7 @@ package awais.instagrabber.utils; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ClipboardManager; import android.content.ContentResolver; @@ -182,7 +183,13 @@ public final class Utils { } final Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); - context.startActivity(i); + try { + context.startActivity(i); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "openURL: No activity found to handle URL view", e); + } catch (Exception e) { + Log.e(TAG, "openURL", e); + } } public static void openEmailAddress(final Context context, final String emailAddress) {