Prevent crash when clicking on URI in chat if not matching app is found

This commit is contained in:
Sylvain Berfini 2023-03-30 15:07:31 +02:00
parent ff38e96722
commit 0708862abe
2 changed files with 6 additions and 2 deletions

View file

@ -14,6 +14,7 @@ Group changes to describe their impact on the project, as follows:
### Fixed ### Fixed
- Admin weren't visible for non admin users in group chat rooms - Admin weren't visible for non admin users in group chat rooms
- Crash when clicking on URI in chat if not matching app is found on Android to handle it
- LIME update threshold wasn't set, causing a request to be made after each REGISTER - LIME update threshold wasn't set, causing a request to be made after each REGISTER
### Changed ### Changed

View file

@ -505,14 +505,17 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
viewLifecycleOwner viewLifecycleOwner
) { ) {
it.consume { url -> it.consume { url ->
val uri = Uri.parse(url)
val browserIntent = Intent( val browserIntent = Intent(
Intent.ACTION_VIEW, Intent.ACTION_VIEW,
Uri.parse(url) uri
) )
try { try {
startActivity(browserIntent) startActivity(browserIntent)
} catch (se: SecurityException) { } catch (se: SecurityException) {
Log.e("[Chat Room] Failed to start browser intent, $se") Log.e("[Chat Room] Failed to start browser intent from uri [$uri]: $se")
} catch (anfe: ActivityNotFoundException) {
Log.e("[Chat Room] Failed to find app matching intent from uri [$uri]: $anfe")
} }
} }
} }