From 4d3ef0debdc4b9875fe9d934ade8006145505158 Mon Sep 17 00:00:00 2001 From: vinceglb Date: Thu, 30 Jul 2026 23:47:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Handle=20missing=20Android=20cam?= =?UTF-8?q?era=20activities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compose/AndroidComposePickerReliabilityTest.kt | 9 +++++++++ .../filekit/dialogs/compose/FileKitCompose.android.kt | 2 ++ 2 files changed, 11 insertions(+) diff --git a/filekit-dialogs-compose/src/androidHostTest/kotlin/io/github/vinceglb/filekit/dialogs/compose/AndroidComposePickerReliabilityTest.kt b/filekit-dialogs-compose/src/androidHostTest/kotlin/io/github/vinceglb/filekit/dialogs/compose/AndroidComposePickerReliabilityTest.kt index fb32a859..fda5a4a8 100644 --- a/filekit-dialogs-compose/src/androidHostTest/kotlin/io/github/vinceglb/filekit/dialogs/compose/AndroidComposePickerReliabilityTest.kt +++ b/filekit-dialogs-compose/src/androidHostTest/kotlin/io/github/vinceglb/filekit/dialogs/compose/AndroidComposePickerReliabilityTest.kt @@ -95,6 +95,15 @@ class AndroidComposePickerReliabilityTest { assertFalse(launched) } + @Test + fun CameraLaunchSafely_whenActivityNotFound_returnsFalse() { + val launched = launchCameraSafely(Uri.parse("content://example.provider/camera/photo.jpg")) { + throw ActivityNotFoundException("No activity found") + } + + assertFalse(launched) + } + @Test fun CameraLaunchSafely_whenNoError_returnsTrue() { val expectedUri = Uri.parse("content://example.provider/camera/photo.jpg") diff --git a/filekit-dialogs-compose/src/androidMain/kotlin/io/github/vinceglb/filekit/dialogs/compose/FileKitCompose.android.kt b/filekit-dialogs-compose/src/androidMain/kotlin/io/github/vinceglb/filekit/dialogs/compose/FileKitCompose.android.kt index bc276998..bda033a9 100644 --- a/filekit-dialogs-compose/src/androidMain/kotlin/io/github/vinceglb/filekit/dialogs/compose/FileKitCompose.android.kt +++ b/filekit-dialogs-compose/src/androidMain/kotlin/io/github/vinceglb/filekit/dialogs/compose/FileKitCompose.android.kt @@ -480,6 +480,8 @@ internal fun launchCameraSafely( ): Boolean = try { launch(uri) true +} catch (_: ActivityNotFoundException) { + false } catch (_: SecurityException) { false }