CodeWebView (app/src/main/java/com/thirtydegreesray/openhub/ui/widget/webview/CodeWebView.java:203-220) routes any tapped link out of the code-preview WebView through its startActivity(Uri) helper, which delegates to AppOpener.launchUrl:
private class WebClientN extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
startActivity(request.getUrl());
return true;
}
}
...
private void startActivity(Uri uri){
if(uri == null) return;
AppOpener.launchUrl(getContext(), uri);
}
AppOpener.launchUrl -> openInCustomTabsOrBrowser -> customTabsIntent.launchUrl(context, Uri.parse(url)) is the path that gets used when a Custom Tabs package is detected. If the user uninstalls that browser between CustomTabsHelper.INSTANCE.getBestPackageName(context) and the subsequent launchUrl, the latter raises ActivityNotFoundException. The exception then propagates all the way back through shouldOverrideUrlLoading, which is the U04 pattern from the WebView posture notes: the WebView's host activity crashes mid-tap.
openInBrowser (the non-Custom-Tabs path) already has a fallback Toast, but the Custom Tabs path does not.
Suggested fix
Wrap the helper's AppOpener.launchUrl call in a try { ... } catch (ActivityNotFoundException) { } so the WebView's host activity survives the rare uninstall-mid-tap case:
private void startActivity(Uri uri){
if(uri == null) return;
try {
AppOpener.launchUrl(getContext(), uri);
} catch (android.content.ActivityNotFoundException e) {
// chosen custom-tabs / browser package disappeared between
// selection and launch
}
}
A PR with the small change is open at #446.
CodeWebView(app/src/main/java/com/thirtydegreesray/openhub/ui/widget/webview/CodeWebView.java:203-220) routes any tapped link out of the code-preview WebView through itsstartActivity(Uri)helper, which delegates toAppOpener.launchUrl:AppOpener.launchUrl->openInCustomTabsOrBrowser->customTabsIntent.launchUrl(context, Uri.parse(url))is the path that gets used when a Custom Tabs package is detected. If the user uninstalls that browser betweenCustomTabsHelper.INSTANCE.getBestPackageName(context)and the subsequentlaunchUrl, the latter raisesActivityNotFoundException. The exception then propagates all the way back throughshouldOverrideUrlLoading, which is the U04 pattern from the WebView posture notes: the WebView's host activity crashes mid-tap.openInBrowser(the non-Custom-Tabs path) already has a fallback Toast, but the Custom Tabs path does not.Suggested fix
Wrap the helper's
AppOpener.launchUrlcall in atry { ... } catch (ActivityNotFoundException) { }so the WebView's host activity survives the rare uninstall-mid-tap case:A PR with the small change is open at #446.