openUri: avoid crash on SecurityException

This commit is contained in:
Pierre-Yves Nicolas
2026-05-30 19:11:10 +02:00
parent a38909fb52
commit eaaf5b01a2

View File

@@ -451,7 +451,7 @@ class MainActivity : ComponentActivity() {
val errorMessage =
"Failed to open URI, scheme=${uriToOpen.scheme}, authority=${uriToOpen.authority}"
logger.e("OpenUri", errorMessage, e)
throw OpenUriException(errorMessage, e)
showToast(getString(R.string.error_occurred))
} catch (_: ActivityNotFoundException) {
showToast(getString(R.string.error_no_app))
}
@@ -494,5 +494,3 @@ class MainActivity : ComponentActivity() {
}
)
}
class OpenUriException(message: String, cause: Throwable) : RuntimeException(message, cause)