Search code examples
javaandroidpythongoogle-drive-apigoogle-drive-android-api

How to programmatically share a google drive link on android?


I have an android app that saves an image into the Google Drive and shares the weblink to my Google App Engine server (python).

    // Create client
    mGoogleApiClient = new GoogleApiClient.Builder(mContext)
        .addApi(Drive.API)
        .addScope(Drive.SCOPE_FILE)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();

   // handling results after uploading
   final DriveOperationResult<Metadata> driveOperationResultHandler = new DriveOperationResult<Metadata>() {

    @Override
    public void onDriveOperationSucceeded(Metadata result) {
        try {
            // Successfully fetched metadata
            onSuccess(driveId,
                      result.getOriginalFilename(),
                      result.getWebContentLink(),
                      result.getWebViewLink(),
                      result.getAlternateLink(),
                      result.getEmbedLink());
        } finally {
            mGoogleDriveClient.disconnectAsync();
        }
    }

Note: result.getEmbedLink() always returns null. Also, result.getAlternateLink() and result.getWebContentLink() are not accessible not accessible if the user is logged-in.

How do I programmatically share the file from Android i.e., make it viewable by everyone (assuming the user is OK with that)


Solution

  • It's not possible with the android API for google drive.