I am using the demo found here as a guide for my app:
I am first using the PickFolderWithOpenerActivity.java to retrieve the Google Drive folder responseID. I want the user to first drill down and select a folder, and then all the files in that folder to be displayed (and to be selectable)
The OpenFileActivityBuilder opens ok in my app and I can then browse the folder structure, and then press the "Select" button in order to select that folder.
In PickFolderWithOpenerActivity.java, I am overwriting the EXISTING_FOLDER_ID with the responseID (this response ID matches the drive folder URL i.e. the part in bold: https://drive.google.com/?authuser=0#folders/0AwbfSlc3Y1XYUXpZU0Vac1JXY28):
So essentially, EXISTING_FOLDER_ID = 0AwbfSlc3Y1XYUXpZU0Vac1JXY28
DriveId driveId = (DriveId) data.getParcelableExtra(
OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
EXISTING_FOLDER_ID = driveId.getResourceId();
I then call the the "ListFilesInFolderActivity.java":
public class ListFilesInFolderActivity extends BaseActivity {
private ListView mResultsListView;
private ResultsAdapter mResultsAdapter;
//private static DriveId sFolderId = DriveId.decodeFromString(EXISTING_FOLDER_ID); // this causes error
@Override
public void onConnected(Bundle connectionHint) {
super.onCreate(connectionHint);
setContentView(R.layout.activity_listfiles);
mResultsListView = (ListView) findViewById(R.id.listViewResults);
mResultsAdapter = new ResultsAdapter(this);
mResultsListView.setAdapter(mResultsAdapter);
showMessage("EXISTING_FOLDER_ID:" + EXISTING_FOLDER_ID);
Drive.DriveApi.fetchDriveId(getGoogleApiClient(), EXISTING_FOLDER_ID)
.setResultCallback(idCallback);
}
final private ResultCallback<DriveIdResult> idCallback = new ResultCallback<DriveIdResult>() {
@Override
public void onResult(DriveIdResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Cannot find DriveId. Are you authorized to view this file?");
return;
}
DriveFolder folder = Drive.DriveApi.getFolder(getGoogleApiClient(), result.getDriveId());
showMessage("Result driveId is: " + result.getDriveId());
folder.listChildren(getGoogleApiClient())
.setResultCallback(metadataResult);
}
};
final private ResultCallback<MetadataBufferResult> metadataResult = new
ResultCallback<MetadataBufferResult>() {
@Override
public void onResult(MetadataBufferResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Problem while retrieving files");
return;
}
mResultsAdapter.clear();
mResultsAdapter.append(result.getMetadataBuffer());
showMessage("Successfully listed files.");
Intent intent2 = new Intent(ListFilesInFolderActivity.this, ListFilesActivity.class);
startActivity(intent2);
}
};
}
This completes ok as I receive the following message:
showMessage("Successfully listed files.");
I then call the ListFilesInFolderActivity which I think is populating the ListView (when I say call, I am using a new intent to show the activity).
But the problem is that only the top level folders and files are listed in the ListView. Not the files from the selected folder.
My intention is to display all the files from that "picked" folder and make them selectable (multi select).
I tried using the "PickFileWithOpenerActivity" but it only lets you choose one file from google drive. I want to be able to select multiple files in a folder. (I take it there is no way to change that)
Could someone take a look at the sample code and let me know if there is anything I need to change to get the ListView to populate with all the files from the SELECTED folder, (and to make the list multi selectable)?
Should I not be using responseID at all? Should I only be using driveId?
Thanks