Wednesday, 4 January 2023

Intent ACTION_OPEN_DOCUMENT_TREE only opens local file browser

When I use the ACTION_OPEN_DOCUMENT intent, Android will allow me to select from the document providers installed on my device (e.g. DropBox, Google Drive, system Stack Traces, images, video, etc.) to navigate to a file.

However, when I use ACTION_OPEN_DOCUMENT_TREE, no such document provider selection is shown. The intent immediately launches the local file browser. This is contrary to the documentation, which states

Activity Action: Allow the user to pick a directory subtree. When invoked, the system will display the various DocumentsProvider instances installed on the device, letting the user navigate through them. Apps can fully manage documents within the returned directory.

Relevant code (using Jetpack Compose)

   Row {
        val launcher = rememberLauncherForActivityResult(OpenDocumentTree()) {
            it?.let { uri ->
               // ...
            }
        }
        Button(onClick = { launcher.launch(null) }) {
           // ..
        }
    }


from Intent ACTION_OPEN_DOCUMENT_TREE only opens local file browser

No comments:

Post a Comment