Fix ActivityNotFoundException

This commit is contained in:
ZaneYork 2020-03-14 11:19:44 +08:00
parent 3611bfe27e
commit d4e8ff6dd5
2 changed files with 11 additions and 6 deletions

View File

@ -9,8 +9,8 @@ android {
applicationId "com.zane.smapiinstaller" applicationId "com.zane.smapiinstaller"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 28 targetSdkVersion 28
versionCode 8 versionCode 10
versionName "1.2.0" versionName "1.2.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true

View File

@ -1,6 +1,7 @@
package com.zane.smapiinstaller.logic; package com.zane.smapiinstaller.logic;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
@ -107,10 +108,14 @@ public class CommonLogic {
} }
public static void openUrl(Context context, String url) { public static void openUrl(Context context, String url) {
Intent intent = new Intent(); try {
intent.setData(Uri.parse(url)); Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url));
context.startActivity(intent); intent.setAction(Intent.ACTION_VIEW);
context.startActivity(intent);
}
catch (ActivityNotFoundException ignored){
}
} }
public static boolean copyToClipboard(Context context, String copyStr) { public static boolean copyToClipboard(Context context, String copyStr) {