From c276b94b89793b7b0af2939c58007e1bd0cce7b0 Mon Sep 17 00:00:00 2001 From: dimitris Date: Fri, 15 May 2026 23:17:13 +0200 Subject: [PATCH] fix(CodeWebView): guard external-link launch with try/catch CodeWebView.shouldOverrideUrlLoading routes tapped links out via the startActivity helper, which delegates to AppOpener.launchUrl. The Custom Tabs path inside AppOpener calls customTabsIntent.launchUrl without a try/catch, so if the chosen custom-tabs package is uninstalled between CustomTabsHelper.getBestPackageName and that launchUrl, the exception propagates back through shouldOverrideUrlLoading and the WebView's host activity crashes mid-tap. The non-Custom-Tabs path (openInBrowser) already shows a fallback Toast, so the matching guard belongs at the helper that fans both paths out. --- .../openhub/ui/widget/webview/CodeWebView.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/thirtydegreesray/openhub/ui/widget/webview/CodeWebView.java b/app/src/main/java/com/thirtydegreesray/openhub/ui/widget/webview/CodeWebView.java index 6e043981..9d37fae1 100644 --- a/app/src/main/java/com/thirtydegreesray/openhub/ui/widget/webview/CodeWebView.java +++ b/app/src/main/java/com/thirtydegreesray/openhub/ui/widget/webview/CodeWebView.java @@ -225,7 +225,13 @@ private String getAccentColor(){ private void startActivity(Uri uri){ if(uri == null) return; - AppOpener.launchUrl(getContext(), uri); + try { + AppOpener.launchUrl(getContext(), uri); + } catch (android.content.ActivityNotFoundException e) { + // The chosen custom-tabs / browser package can disappear between + // selection and launch (uninstall mid-tap, etc.). Swallow the + // exception so the host activity does not crash. + } } }