简体   繁体   中英

How to share Google Drive file from Android app?

My Android app creating a file on Google Drive using new Google Drive API. I'm getting DriveFile object successfully.

The question is: how to share this file from my app? Links to relevant topics and especially code samples are appreciated.

The Android-specific API does not yet support sharing. You can use the RESTful web API to do this. See permissions .

From a DriveId you can get the resourceId, which is the id you need in order to access a file in the web API.

Permission newPermission = new Permission();
newPermission.setValue(emailvalue);
newPermission.setType(type);
newPermission.setRole(role);
try {
   service.permissions().insert(fid, newPermission).execute();
   showToast("Done Shared successfully!!!!!!");
} catch (IOException e) {
  System.out.println("An error occurred: " + e);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM