Skip to content

Commit a9642a9

Browse files
committed
fix: guard file chooser launch against missing picker
The ActivityNotFoundException can also happen at launch() time, not just createIntent(). Wrap the launcher call so devices without a file picker return null to WebView cleanly.
1 parent 00f924d commit a9642a9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

app/src/main/java/com/pumperly/app/MainActivity.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,12 @@ class MainActivity : ComponentActivity() {
340340
// Cancel any pending callback (null signals cancellation to WebView)
341341
fileUploadCallback?.onReceiveValue(null)
342342
fileUploadCallback = filePathCallback
343-
fileChooserLauncher.launch(chooserIntent)
343+
try {
344+
fileChooserLauncher.launch(chooserIntent)
345+
} catch (_: android.content.ActivityNotFoundException) {
346+
fileUploadCallback?.onReceiveValue(null)
347+
fileUploadCallback = null
348+
}
344349
}
345350

346351
private fun showErrorPage(type: WebViewError) {

0 commit comments

Comments
 (0)