Android OPEN_DOCUMENT_TREE intent root locations

android-5.0-lollipop, android-intent, google-drive-api, storage-access-framework

Solution

The result at my end is exactely same with yours, that is, cannot select subtree on Google Drive.

Based on the Android official sample about OPEN_DOCUMENT_TREE: The system displays all DocumentsProvider instances that support subtree selection

So I think the reason is that Google Drive DocumentsProvider instance did not support handle OPEN_DOCUMENT_TREE yet.

Problem

I'm using the Directory Selection API, which was introduced in Android 5.0 (API level 21) to let users pick a directory to save a file to. To select a directory I build and send an ACTION_OPEN_DOCUMENT_TREE intent like in the following code: ``` Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivityForResult(intent, REQUEST_CODE_OPEN_DIRECTORY); ``` I get the following popup: However, if I let users choose a file using ACTION_OPEN_DOCUMENT intent: ``` Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); startActivityForResult(intent, FILE_CHOOSER_ACTIVITY_REQUEST_CODE); ``` Then, I get the following popup: I'm testing it in my Android 5.0.1 Nexus Tab 10. Why do I get different root locations using ACTION_OPEN_DOCUMENT_TREE and ACTION_OPEN_DOCUMENT? Maybe only Internal Storage Document Provider instance supports subtree selection? I would also like allowing users pick a Google Drive directory using ACTION_OPEN_DOCUMENT_TREE. Both ACTION_OPEN_DOCUMENT_TREE and ACTION_OPEN_DOCUMENT reference say: When invoked, the system will display the various DocumentsProvider instances installed on the device, letting the user navigate through them. Thank you very much in advance

Original source