martes, 7 de enero de 2014

Google Drive (Android and Javascript)

All started with a bug in Google's Developer Console. They are making some changes there and they're also mixing some old information with the new one.

Technical support is free but not for the most important stuff. If you want real phone support you need to pay $150 montly (too much for a simple developer who has an issue like this one once in a year I guess)

So, I was not able to define my API access for using Google Drive API form Android (I need to browse all the files from a user and when he/she selects a file I need to download that file to the Android phone).

I can not use another package name and SHA-1 combination because I already have this app uploaded on Google Play and don't want to create a new app just because of this error!

So, resuming: I can not use the Android's Drive API! So I figure what if I use the Javascript API for Drive from Android? Sure that's possible! I have a beautiful WebView I can use... So let's see the code:

1) First you need the HTML in your server (you can also try using this HTML inside your Android's code but I didn't test that)
  • This HTML will cover the following functionality for using Google Drive API:
  • a) Check if my App (defined in the Google's Developer Console) has permission for browsing this user's files in Drive.
  • b) List all the files I want from this user's account.
  • c) Tell me about the selected URL and the file name to download on the Android phone.

2) Then you need a webView in your Android app and some smart ideas :-)

I let you here a link to my Google Code repository so you can download and try yourself if it's what you are looking form


This is something I'll use from now on. Because this gives me more freedom to change the project properties in my Drive API configuration without changing anything in my Android API key or something...