Skip to content

Avoid crash when no app can open an external article link#214

Closed
jim-daf wants to merge 1 commit into
itkach:masterfrom
jim-daf:fix/external-link-no-handler-crash
Closed

Avoid crash when no app can open an external article link#214
jim-daf wants to merge 1 commit into
itkach:masterfrom
jim-daf:fix/external-link-no-handler-crash

Conversation

@jim-daf

@jim-daf jim-daf commented Jun 4, 2026

Copy link
Copy Markdown

What

When an article links to an external URL, ArticleWebView.shouldOverrideUrlLoading hands it off with a raw getContext().startActivity(new Intent(Intent.ACTION_VIEW, uri)). On a device with no app able to handle the URI that call throws ActivityNotFoundException and the article view crashes.

This wraps the launch in a try/catch and shows a short toast when nothing can open the link, mirroring the existing msg_no_activity_to_get_content handling for the open-file case. Links that resolve behave exactly as before.

Changes

                 if (isExternal(uri)) {
                     Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
-                    getContext().startActivity(browserIntent);
+                    try {
+                        getContext().startActivity(browserIntent);
+                    } catch (ActivityNotFoundException e) {
+                        Toast.makeText(getContext(), R.string.msg_no_activity_to_open_link,
+                                Toast.LENGTH_SHORT).show();
+                    }
                     return true;
                 }

A msg_no_activity_to_open_link string is added next to the existing msg_no_activity_to_get_content entry.

Closes #213

When an article links to an external URL, shouldOverrideUrlLoading sends
it out with startActivity(ACTION_VIEW). On a device with no app able to
handle the URI that call throws ActivityNotFoundException and the article
view crashes.

Wrap the launch in a try/catch and show a short toast, mirroring the
existing msg_no_activity_to_get_content handling.
@jim-daf

jim-daf commented Jun 4, 2026

Copy link
Copy Markdown
Author

Closing this, the external link guard is already handled in #211. Sorry for the duplicate.

@jim-daf jim-daf closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External links can crash the article view with ActivityNotFoundException

1 participant