Android : Android. Can't list files in a folder that was opened by Drive.DriveApi.newOpenFileActivityBuilder()

on Sunday, September 7, 2014


Using code at https://github.com/googledrive/android-demos, I opened a folder from my app with PickFolderWithOpenerActivity.java;



@Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
IntentSender intentSender = Drive.DriveApi
.newOpenFileActivityBuilder()
.setMimeType(new String[] { DriveFolder.MIME_TYPE })
.build(getGoogleApiClient());


The driveId of the choosen folder is returned with



DriveId driveId = (DriveId) data.getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);


I use the same driveId in ListFilesInFolderActivity.java to get the list of files in the choosen folder. This is the code



Drive.DriveApi.fetchDriveId(getGoogleApiClient(), EXISTING_FOLDER_ID)
.setResultCallback(idCallback);


However, access fails with this message -



"Cannot find DriveId. Are you authorized to view this file?"


The Google Drive API for android docs say -



The Google Drive Android API currently only supports drive.file and drive.appfolder authorization scopes.


And authorization scope docs say



scope drive.file means Per-file access to files created or opened by the app


Still the above doesn't works. What am I missing?


0 comments:

Post a Comment