Protection against ActivityNotFoundException.
Should fix https://sentry.tools.element.io/organizations/element/issues/974670/events/f074c0a4da444a5bacc4ef8f8fd5dbea/
This commit is contained in:
parent
7a9a7c4af5
commit
31ccdeab51
1 changed files with 12 additions and 2 deletions
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
package io.element.android.libraries.mediapickers.api
|
package io.element.android.libraries.mediapickers.api
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import androidx.activity.compose.ManagedActivityResultLauncher
|
import androidx.activity.compose.ManagedActivityResultLauncher
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around [ManagedActivityResultLauncher] to be used with media/file pickers.
|
* Wrapper around [ManagedActivityResultLauncher] to be used with media/file pickers.
|
||||||
|
|
@ -25,11 +27,19 @@ class ComposePickerLauncher<Input, Output>(
|
||||||
private val defaultRequest: Input,
|
private val defaultRequest: Input,
|
||||||
) : PickerLauncher<Input, Output> {
|
) : PickerLauncher<Input, Output> {
|
||||||
override fun launch() {
|
override fun launch() {
|
||||||
managedLauncher.launch(defaultRequest)
|
try {
|
||||||
|
managedLauncher.launch(defaultRequest)
|
||||||
|
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||||
|
Timber.w(activityNotFoundException, "No activity found")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun launch(customInput: Input) {
|
override fun launch(customInput: Input) {
|
||||||
managedLauncher.launch(customInput)
|
try {
|
||||||
|
managedLauncher.launch(customInput)
|
||||||
|
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||||
|
Timber.w(activityNotFoundException, "No activity found")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue