Repository navigation
Conversation
When the document viewer routes an http(s) or other ://-scheme link out with startActivity(ACTION_VIEW) and no app on the device can open it, the call throws ActivityNotFoundException and the activity crashes. Wrap the launch in a try/catch and show a short toast when nothing can open the link.
Author
|
Closing this, it duplicates #45. Apologies for the noise. |
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.
What
DocViewerActivity.overrideUrlLoadingsends://-scheme links to an external app with a rawstartActivity(Intent(Intent.ACTION_VIEW, ...)). When no installed app can open the link that call throwsActivityNotFoundExceptionand the viewer crashes.This wraps the launch in a try/catch and shows a short toast when nothing can open the link. The
mailto:branch already goes throughIntent.createChooser, so it is left as is. Links that resolve behave exactly as before.Changes
val uri = Uri.parse(path) val intent = Intent(Intent.ACTION_VIEW, uri) - startActivity(intent) + try { + startActivity(intent) + } catch (e: ActivityNotFoundException) { + Toast.makeText( + this@DocViewerActivity, + getString(R.string.document_viewer_no_app_for_link), + Toast.LENGTH_SHORT + ).show() + } trueA
document_viewer_no_app_for_linkstring is added alongside the existingdocument_viewer_*entries.Closes #46