From d4e8ff6dd52907af0fa0322814e70cec5d7f90f4 Mon Sep 17 00:00:00 2001 From: ZaneYork Date: Sat, 14 Mar 2020 11:19:44 +0800 Subject: [PATCH] Fix ActivityNotFoundException --- app/build.gradle | 4 ++-- .../com/zane/smapiinstaller/logic/CommonLogic.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 970055f..a946a5e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.zane.smapiinstaller" minSdkVersion 19 targetSdkVersion 28 - versionCode 8 - versionName "1.2.0" + versionCode 10 + versionName "1.2.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java b/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java index 1a16519..d4f89a6 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/CommonLogic.java @@ -1,6 +1,7 @@ package com.zane.smapiinstaller.logic; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -107,10 +108,14 @@ public class CommonLogic { } public static void openUrl(Context context, String url) { - Intent intent = new Intent(); - intent.setData(Uri.parse(url)); - intent.setAction(Intent.ACTION_VIEW); - context.startActivity(intent); + try { + Intent intent = new Intent(); + intent.setData(Uri.parse(url)); + intent.setAction(Intent.ACTION_VIEW); + context.startActivity(intent); + } + catch (ActivityNotFoundException ignored){ + } } public static boolean copyToClipboard(Context context, String copyStr) {