28

I integrated Dropbox with my app in a matter of hours as the SDK was clearly described and had good examples of usage.

Google Drive seems to only have a "one size fits all" Gdata SDK which is very heavy (with the many dependencies, it triples the size of my app) and not very intuitive as it is so low level. I'm sure it makes perfect sense when you know how to use it but as I cannot find any real samples of usage I am really struggling.

Are there any sample apps available that I can look at and learn from? If not, if anybody has a simple example of uploading and downloading files to get me started it would be much appreciated.

2 Answers2

20

EDIT: Since we launched the Google Drive SDK v2 the preferred way is to use the Drive API (and not the Document List API). There is a full-access scope which gives you access to listing and reading all the drive files and which can be used in Android apps easily since our newer client library is Android-friendly! I also recommend watching this talk from Google IO which is explains how to integrate mobile apps with Drive.

You can also use the per-file scope and integrate with the Drive Android App intents.

We are coming with full sample apps and dev guides so please stay put.


This has already been answered in this SO post.

Basically currently the Google Drive SDK is targeted at Chrome Web Store web applications. To use Google Drive on Android today you will have to use the GData Document List API.

The GData client libraries are older (pre-Android world :)) and don't play well with Android. As explained in the other post by Alain you have the choice of still trying to use the GData client library or use the newer google-api-java-client but since it doesn't have Document List API service classes you will have to manually implement it.

Probably the simplest and most lightweight option would be to use the HTTP based REST protocol of the API directly along with a good XML parser. The protocol is described in the documentation of the Google Document List API just find the tabs that reads "protocol" wherever there is code samples in the page.

Last option you wait until we eventually release something better and newer that plays well with Android :)

Community
  • 1
  • 1
Nicolas Garnier
  • 12,134
  • 2
  • 42
  • 39
  • thanks. Unfortunately it is the "manually implement it" I am struggling with as there are no examples of usage. My question was asking for samples which the other question does not cover. Nice to know that there will be a better solution in future though. –  Apr 26 '12 at 09:30
  • There is a guide for writing new data models for the google-api-java-client which starts here: http://code.google.com/p/gdata-java-client/wiki/MigratingToGoogleApiJavaClient You can start reading where it says "First, you need to invest in writing a custom data model for the Google API...". You will need good knowledge of the Document List API and GData though (and also time). Good luck if you go this way and don't forget to share it ;) – Nicolas Garnier Apr 26 '12 at 09:42
  • Also it might **way** simpler and **way** more lightweight to use raw HTTP requests directly and a good XML parser :) Just look at the *protocol* tabs in the Google document list API doc: https://developers.google.com/google-apps/documents-list – Nicolas Garnier Apr 26 '12 at 09:45
  • There doesnt appear to be a "Protocol" tab for the current version. Only the deprecated versions. –  Apr 26 '12 at 11:05
  • 2
    I definitely see some here: https://developers.google.com/google-apps/documents-list/ – Nicolas Garnier Apr 26 '12 at 11:20
  • I've added a picture of what I see to my question. Am I missing something? Definitely no links to "Protocol" –  Apr 26 '12 at 11:34
  • You are already on the right page :) Just keep scrolling down until you see some code samples. For instance "Getting general information about a user's account" there will be a "Protocol" tab to change the sample from .NET to HTTP requests. I recommend you try out the OAuth 2.0 playground it's a useful tool to try these requests easily: https://code.google.com/oauthplayground/ – Nicolas Garnier Apr 26 '12 at 11:44
  • Got it thanks. I apologise. The "Protocol" section of the deprecated versions made me think that is what you were referring to. –  Apr 26 '12 at 11:55
  • What about Ruby.. I implemented Google Drive but I'm struggling making Google Document List with OAuth2. There is absolutely zero examples/code around. Why not implement simple index/listing in Google Drive API? It would be super useful, even because it would work with existing Discovery libraries. – kain Apr 27 '12 at 00:35
  • 3
    Nivco, thank you so much for your comment! I actually made an Android app wich uses OAuth and HTTP requests to get and put some information to Google Drive. No GData library at all. Document List API helped me a lot in this. – lomza Jun 06 '12 at 06:00
  • Hi, could we get either an example project or a tutorial for how to make an Android app that can access Google Drive? There's tons of code snippets for Android but without seeing them all in one project, I'm getting lost. DrEdit (https://developers.google.com/drive/examples/index) looks like exactly what I want, except it's available for every platform except Android. – ArtOfWarfare Aug 28 '12 at 16:05
  • Hey guys, Now that the Google Play services just launched (we needed that part for Authorization) we'll be able to publish an Android sample along with a dev guide very soon. In the mean time please check out our Android dev page which explains how to use the Android Drive app intents: https://developers.google.com/drive/integrate-android-ui – Nicolas Garnier Sep 27 '12 at 14:25
  • Lomza would you be able to help me use drive via http requests? http://stackoverflow.com/questions/13055871/android-google-drive-http-request – crazyfool Oct 25 '12 at 20:21
  • thanks for returning to edit this answer, I've been waiting for this for a while... – sethro Nov 27 '12 at 19:37
0

Note that the sample app that they published for using Google Drive (dredit) includes jars for Android:

/dredit/war/WEB-INF/lib/google-api-client-android2-1.8.0-beta-sources.jar

Could be a red-hearing, but this seems to imply that the Java version of the sample app could be used on Android?

Tom
  • 17,103
  • 8
  • 67
  • 75