fix(webview): guard external-link launches with try/catch#76
Open
jim-daf wants to merge 1 commit into
Open
Conversation
DocsViewerActivity and BackupWebView both route tapped links to the system browser with raw context.startActivity(intent) inside shouldOverrideUrlLoading. If the device has no app that can handle the link the call raises ActivityNotFoundException and the host crashes mid-tap. In BackupWebView the call sits inside a Dispatchers.IO coroutine, so the failure brings the process down even more abruptly. Wrap both in try/catch (ActivityNotFoundException) and fall back to a Toast (no_app_to_open_link). On the BackupWebView side the Toast is wrapped in withContext(Dispatchers.Main) since the catch fires on Dispatchers.IO.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #75.
DocsViewerActivityandBackupWebViewboth route tapped links to the system browser with rawcontext.startActivity(intent)calls insideshouldOverrideUrlLoading. If nothing on the device handles the link (no browser, custom scheme, etc.) the call raisesActivityNotFoundExceptionand the host crashes mid-tap. InBackupWebViewthe call sits inside aDispatchers.IOcoroutine, so the failure brings the process down even more abruptly.Wrap both launches in
try { ... } catch (ActivityNotFoundException) { ... }and fall back to a short Toast (no_app_to_open_link). On theBackupWebViewside the Toast is wrapped inwithContext(Dispatchers.Main)since the catch fires onDispatchers.IO.Adds the matching
no_app_to_open_linkstring so the message stays translatable. Happy path is unchanged.