Skip to content

Commit 45314e0

Browse files
committed
fix(android): Update Intent actions for file picking
Restricts the usage of `ACTION_PICK` to `image/*` mime types only. Replaces `ACTION_GET_CONTENT` with `ACTION_OPEN_DOCUMENT` for general file selection to ensure consistent document access.
1 parent e5c7c34 commit 45314e0

File tree

1 file changed

+3
-3
lines changed
  • android/src/main/kotlin/com/mr/flutter/plugin/filepicker

1 file changed

+3
-3
lines changed

android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ object FileUtils {
142142
if (type == "dir") {
143143
intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
144144
} else {
145-
if (type != "*/*") {
145+
if (type == "image/*") {
146146
intent = Intent(Intent.ACTION_PICK)
147147
val uri = (Environment.getExternalStorageDirectory().path + File.separator).toUri()
148148
intent.setDataAndType(uri, type)
@@ -159,7 +159,7 @@ object FileUtils {
159159
intent.putExtra(Intent.EXTRA_MIME_TYPES, allowedExtensions)
160160
}
161161
} else {
162-
intent = Intent(Intent.ACTION_GET_CONTENT).apply {
162+
intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
163163
addCategory(Intent.CATEGORY_OPENABLE)
164164
type = this@startFileExplorer.type
165165
if (!allowedExtensions.isNullOrEmpty()) {
@@ -631,4 +631,4 @@ object FileUtils {
631631

632632
file.delete()
633633
}
634-
}
634+
}

0 commit comments

Comments
 (0)