0

I want to open a File Picker to selecting Folders in Google Drive. But my File Picker only shows local folders.

Connection to Google Drive is successfully established. I query the root folder of Google Drive and want do open the File Picker on root level immediately after this query.

In my GoogleDriver.class I call the picker like:

Activity.getInstance().openFilePicker(mDriveServiceHelper);

From this Activity I call:

public void openFilePicker(DriveServiceHelper mDriveServiceHelper) {
    if (mDriveServiceHelper != null) {
        Intent pickerIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
        pickerIntent.addCategory(Intent.CATEGORY_DEFAULT);          
        startActivityForResult(pickerIntent, REQUEST_CODE_OPEN_DOCUMENT);
    }
}

IntentFilter in manifest

<intent-filter>
    <action android:name="android.intent.action.OPEN_DOCUMENT_TREE"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="audio/*" />
</intent-filter>

Thanks for supporting me Alejandro

Now the picker opens, but not in Google Drive, it opens locally.

  • Of course. There is nothing in the intent that has anything to do with google drive to begin with. Or with opening in a certain folder. – blackapps Jan 30 '21 at 16:16
  • Further it is unclear what you want with your intent filter. And you did not post code handling such an intent. – blackapps Jan 30 '21 at 16:19
  • what I have to change, to get content of google drive? – Alejandro Gomez Jan 30 '21 at 16:28
  • 1
    You can not select a folder from Google drive using ACTION_OPEN_DOCUMENT_TREE. You can only select a file from Google drive using ACTION_OPEN_DOCUMENT or ACTION_GET_CONTENT. – blackapps Jan 30 '21 at 18:29
  • OK, thank you. Since I want to give users the option to choose the folder themselves, I guess I'll have to build it myself – Alejandro Gomez Jan 30 '21 at 21:41
  • If Google drive does not give you uries for folders then why do you think you can build up an uri for a folder. An uri that would be accepted by Google drive? – blackapps Jan 30 '21 at 22:09
  • I will query Google Drive with api v3 and work with IDs – Alejandro Gomez Jan 30 '21 at 22:13
  • I query all folders that contain the desired files. I would have preferred to let this do by the user, as this would be more logical in the process. – Alejandro Gomez Jan 30 '21 at 22:34

0 Answers0