Skip to content

Guard external link launch in the changelog WebView#179

Open
jim-daf wants to merge 1 commit into
MuntashirAkon:devfrom
jim-daf:fix/whatsnew-external-link-crash
Open

Guard external link launch in the changelog WebView#179
jim-daf wants to merge 1 commit into
MuntashirAkon:devfrom
jim-daf:fix/whatsnew-external-link-crash

Conversation

@jim-daf

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

Copy link
Copy Markdown

What

The What's New screen renders the changelog in a WebView and routes any tapped link out with a raw startActivity(Intent(Intent.ACTION_VIEW, url)). When no installed app can handle the link that call throws ActivityNotFoundException and the screen crashes.

This wraps the launch in a try/catch and shows a short toast when nothing can open the link, using the existing showToast extension. Links that resolve behave exactly as before.

Change

app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewFragment.kt:

                     val url = request?.url ?: return false
                     //you can do checks here e.g. url.host equals to target one
-                    startActivity(Intent(Intent.ACTION_VIEW, url))
+                    try {
+                        startActivity(Intent(Intent.ACTION_VIEW, url))
+                    } catch (e: ActivityNotFoundException) {
+                        showToast("No app found to open this link")
+                    }
                     return true

The What's New WebView routes links out with a raw
startActivity(ACTION_VIEW). When no app on the device can open the URI
that call throws ActivityNotFoundException and the screen crashes.

Wrap the launch in a try/catch and show a short toast when nothing can
open the link.
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.

1 participant