Skip to content

[Bug]: FilePickerResultContracts.PickMedia() and PickDocumentFile() #75

Description

@pengkongkong

Describe the bug

Using PickMedia() does not open the gallery, but behaves like PickDocumentFile()

        findViewById<Button>(R.id.btn).setOnClickListener {
            val config = DocumentFilePickerConfig(
                popUpText = "File Media",
                allowMultiple = true,
                maxFiles = 10,
                mMimeTypes = listOf("application/pdf", "image/*")
            )

            val config2 = PickMediaConfig(
                popUpIcon = R.drawable.ic_launcher_foreground,
                popUpText = "Pick Media",
                allowMultiple = true,
                maxFiles = 5,
                mPickMediaType = PickMediaType.ImageAndVideo
            )
            launcher.launch(config)
            //launcher.launch(config2)
        }
        launcher = registerForActivityResult(FilePickerResultContracts.AnyFilePicker()) { result ->
            if (result.errorMessage != null) {
                Log.e("Picker", result.errorMessage ?: "")
            } else {
                val uri = result.selectedFileUri
                val filePath = result.selectedFilePath
                Log.e("Picker--", "${uri?.path} $filePath")
            }
        }

Calling launcher.launch(config) or launcher.launch(config2) both open the document selection. Is there something I haven't set up? Or do I need to manually add some permissions? Additionally, when I set maxFiles = 1, an error occurs. How can I set it so that only one file or photo can be selected. Looking forward to your reply

Library Version

0.6.0

Steps to reproduce

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions