google-drive-android-api , Handling of Thumbnails in Google Drive Android API (GDAA)

Handling of Thumbnails in Google Drive Android API (GDAA)


Tag: google-drive-android-api

I've run into the following problem when porting an app from REST API to GDAA.
The app needs to download some of (thousands of) JPEG images based on user selection. The way this is solved in the app is by downloading a thumbnail version first, using this construct of the REST API:

  private static InputStream getCont(String rsid, boolean bBig){
    InputStream is = null;
    if (rsid != null) try {
      File gFl = bBig ?
      mGOOSvc.files().get(rsid).setFields("downloadUrl"  ).execute():
      if (gFl != null){
        GenericUrl url = new GenericUrl(bBig ?  gFl.getDownloadUrl() : gFl.getThumbnailLink());
        is = mGOOSvc.getRequestFactory().buildGetRequest(url).execute().getContent();
    } catch (UserRecoverableAuthIOException uraEx) {
    } catch (GoogleAuthIOException gauEx) {}
    catch (Exception e) { }
    return is;

It allows to get either a 'thumbnail' or 'full-blown' version of an image based on the bBig flag. User can select a thumbnail from a list and the full-blown image download follows (all of this supported by disk-base LRU cache, of course).
The problem is, that GDAA does not have an option to ask for reduced size / thumbnail version of an object (AFAIK), so I have to resort to combining both APIs, which makes the code more convoluted then I like (bottom of the page). Needles to state that the 'Resource ID' needed by the REST may not be immediately available.
So, the question is: Is there a way to ask GDAA for a 'thumbnail' version of a document?


Downloading thumbnails isn't currently available in the Drive Android API, and unfortunately I can't give a timeframe to when it will be available. Until that time, the Drive Java Client Library is the best way to get thumbnails on Android.

We'd appreciate if you go ahead and file a feature request against our issue tracker:

That gives requests more visibility to our teams internally, and issues will be marked resolved when we release updates.


Unable to get custom property via Android Drive API

Create a file and query file with custom property work fine, but it cannot retrieve custom property in queryChildren() ResultCallback. Here is the CustomProperty definition: /** * CustomPropertyKey: Uploaded file's hash code */ public static final CustomPropertyKey CustomPropertyKeyFileHash = new CustomPropertyKey("fileHash", CustomPropertyKey.PUBLIC); query conditions: Query query = new Query.Builder() .addFilter(...

Using Google Drive to backup and restore SQLite Database

I've managed to create a backup of my database on an SD card and restore from there but realized that the purpose of my backup is to ensure the safety of the data and in this case if the physical device itself is damaged, lost, or spontaneously combusts so will...

Dependency ignored because of conflict Android studio

I'm trying to add the following dependency but it is ignore. I can't understand how to resolve it please help me Thank you. Dependency compile '' Waring for ignoring dependency Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case...

Get Access Token From Google Drive API by GoogleAuthUtil in Android

I got a weird problem in using GoogleAuthUtil when accessing the Google Drive API. Following is my code, @Override protected String doInBackground(String... params){ String accountName = params[0]; //String scopes = "oauth2:profile email"; // This can work ! String scopes = ""; String token = null; try{ token = GoogleAuthUtil.getToken(getApplicationContext(), accountName,...

“Cannot find DriveId. Are you authorized to view this file?”: Even if EXISTING_FOLDER_ID is set manually

I am having a look at here from github. I can create a file and a folder successfully by reading the code provided in github. But I am not being able to edit the file or create a file/folder in any specific folder. The main problem would be using emulator,...

Delete / trash file from android using

I need to delete files from Google Drive using From what I've read here and across the web there is no support for file deletion in the "new API". Is that (still) correct? I mean the API isn't that new anymore ... I also read about the "clear contents...

Cannot access Google Drive from 2 different device

I have an app which creates a word file on the Google Drive with some text. If I try to access the word file on the Google Drive from the device In which I have created that file, then it works and everything thing goes smooth, and I can able...

Error cannot be resolved

I am working on Android Google Drive. As of now I am using the github sample code Android Demos. I am getting an error of The import cannot be resolved and The import cannot be resolved I am using the updated Google play service and I have imported...

cannot get folderId that i just created on google drive

public class Helpers extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { SharedPreferences preferences; private static final String TAG = "BaseDriveActivity"; public static String EXISTING_FOLDER_ID; protected static final int REQUEST_CODE_RESOLUTION = 1; protected static final int NEXT_AVAILABLE_REQUEST_CODE = 2; public static final String folderId = "FOLDER_ID"; public static final String fileName = "folderId";...

How to send multiple images those are present in folder to the google drive in android programmatically?

I want to send multiple images those are present in my internal storage and when i selects that folder i want upload that folder into google drive. i have tried this google drive api for android and i have used the below code but it shows some error in...

Google Drive Android SDK: where to start from?

I have been looking all day at the Google Drive SDK for Android, but I am a bit confused. I need to make the list of folders and files in the user Google Drive account. I thought that was a simple, basic standard feature, but maybe not... Please can you...

Couldn't append the text onto a Google Drive File

I am trying to append text to a text file on the Google Drive. But when I write, it whole file is overwritten. Why can't I just add the text in the end of the file? DriveFile file = Drive.DriveApi.getFile(mGoogleApiClient, id);, DriveFile.MODE_WRITE_ONLY, null).setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() { @Override public void onResult(DriveApi.DriveContentsResult...

User disconnecting app in Drive causes loss of data under FILE scope

I've run into this issue a few times, but could never point my finger on it, attributing it to GDAA's latency, my buggy code, etc... I finally managed to come up with a scenario where I can safely reproduce it, so I would like to ask people who know if...

Handling of Thumbnails in Google Drive Android API (GDAA)

I've run into the following problem when porting an app from REST API to GDAA. The app needs to download some of (thousands of) JPEG images based on user selection. The way this is solved in the app is by downloading a thumbnail version first, using this construct of the...

Upload text file to Google Drive using Android

Edited: I have set my text into a string like so: String text = ("Hello!"); I want to turn this into a plain text file and then upload to a Google Drive Folder. I have tried on the code below, but it is not complete so I cannot say what...

Google OAuth 2.0 and debug key for Google Drive API

I've set up 2 Client IDs for Android application in the GoogleDriveAPI console: the first for the release APK and the second for Debug purposes. Everything ok with the released app, but my issue is only related to the second Client ID. I'm getting this exception: after the following...

The lightest (most lightweight) Google Drive REST API query/response?

When initializing the REST Google Drive API in an Android app, I need to 'poke' the server to produce the UserRecoverableAuthIOException In order to minimize the network traffic, I'm searching for the most 'lightweight' request that would produce such an exception. Currently, I use the following construct: svc; svc.files().get("root").setFields("title").execute();...