问题
I tried to access my data in Google Drive over Google Drive Android API (not Web API). What is crazy, that when I use this access, I can access only small part of disk (just a one folder and a few files). I tried to use example code and still, result is same. Any idea what could be wrong?
Authorizing
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstance);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
Reading content
@Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
Query query = new Query.Builder()
.addFilter(Filters.or(
Filters.eq(SearchableField.MIME_TYPE, "text/html"),
Filters.eq(SearchableField.MIME_TYPE, "text/plain")))
.build();
Drive.DriveApi.query(getGoogleApiClient(), query).setResultCallback(metadataCallback);
}
ResultCallback<MetadataBufferResult> childrenRetrievedCallback = 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.");
}
};
回答1:
As API documentation:
Note: The Google Drive Android API currently only supports drive.file
and drive.appfolder
authorization scopes. If your application requires additional permissions or features not yet available in the Drive Android API, you must use the Google APIs Java Client.
I think you need drive
authorization, but this is not ready for Android API.
来源:https://stackoverflow.com/questions/27714031/authorizing-the-google-drive-android-api