Closed ravi-vihaaInfotech closed 6 years ago
Are you still having this issue?
DriveApi.DriveContentsResult has been deprecated, please let us know if you are still having issues with the new recommendation. https://developers.google.com/android/reference/com/google/android/gms/drive/DriveApi.DriveContentsResult
I have created demo Application for google drive file sharing into my server. Below is my Process
Have enable google drive api in console
Have connected googleApiClient
Have fire intent for opening google drive file list
IntentSender intentSender = Drive.DriveApi .newOpenFileActivityBuilder() .setMimeType(new String[]{"application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.google-apps.spreadsheet", "application/vnd.google-apps.document", "application/vnd.google-apps.presentation"})
startIntentSenderForResult(intentSender, REQUEST_CODE_OPENER, null, 0, 0, 0);
And onActivityResult code and downloadFile code as below
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { if (resultCode == RESULT_OK) { DriveId driveId = (DriveId) data.getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID); DriveFile selectedFile = driveId.asDriveFile(); selectedFile.getMetadata(getGoogleApiClient()).setResultCallback(metadataRetrievedCallback); } } catch (Exception e) { e.printStackTrace(); } } ResultCallback metadataRetrievedCallback = new
ResultCallback() {
@Override
public void onResult(DriveResource.MetadataResult result) {
if (!result.getStatus().isSuccess()) {
AppLog.e("problem", "Problem while trying to fetch metadata");
return;
}
Metadata metadata = result.getMetadata();
private class FileDownloadTask extends AsyncTask<String, Void, String> {
}
ResultCallback contentsOpenedCallback =
new ResultCallback() {
@Override
public void onResult(DriveApi.DriveContentsResult result) {
if (!result.getStatus().isSuccess()) {
return;
}