I have some files in my Google Drive that others have shared with me and I would like to be able to query them. Unfortunately the MetadataBuffer' result count is 0
This is the code:
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(com.google.android.gms.drive.Drive.API)
.addScope(com.google.android.gms.drive.Drive.SCOPE_FILE).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).build();
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
public void onConnected(Bundle arg0) {
Query query = new Query.Builder().addFilter(Filters.sharedWithMe()).build();
Drive.DriveApi.query(mGoogleApiClient, query).setResultCallback(metadataCallback);
}
private ResultCallback<DriveApi.MetadataBufferResult> metadataCallback =
new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
if (!result.getStatus().isSuccess()) {
Log.d(TAG, "Problem while retrieving results");
return;
}
MetadataBuffer buffer = result.getMetadataBuffer();
if(buffer != null) {
int cnt = buffer.getCount();
Log.d(TAG, "BUFFER COUNT: " + cnt);
for(int i = 0; i < cnt; i++) {
Metadata meta = buffer.get(i);
Log.d(TAG, meta.getTitle());
}
buffer.close();
}
}
};
....................
I am using the new Google Drive and I also tried moving some shared files from the Incoming Folder into the My Drive root. Still nothing. I would appreciate any help and suggestions.