Skip to content

Commit e36c529

Browse files
Changed: Only show system chooser if ActivityNotFoundException is thrown when opening url
1 parent dd952a9 commit e36c529

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

termux-shared/src/main/java/com/termux/shared/interact/ShareUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.Manifest;
44
import android.app.Activity;
5+
import android.content.ActivityNotFoundException;
56
import android.content.ClipData;
67
import android.content.ClipboardManager;
78
import android.content.Context;
@@ -97,9 +98,11 @@ public static void openURL(final Context context, final String url) {
9798
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
9899
try {
99100
context.startActivity(intent);
100-
} catch (Exception e) {
101+
} catch (ActivityNotFoundException e) {
101102
// If no activity found to handle intent, show system chooser
102103
openSystemAppChooser(context, intent, context.getString(R.string.title_open_url_with));
104+
} catch (Exception e) {
105+
Logger.logStackTraceWithMessage(LOG_TAG, "Failed to open url \"" + url + "\"", e);
103106
}
104107
}
105108

0 commit comments

Comments
 (0)