Sunday, July 28, 2013

Reading Google Spreadsheets from an Android App

Well, I've done it. It took me two serious days of wading through the mess that is the gdata APIs (myths and outdated versions abound) and the OAuth2 APIs (same caveats apply) and I was finally able to read the list of my own personal spreadsheets in Google Docs, and print their names out from an Android application.

It was very important to me to be able to use Android's own build-in account mechanism, which took a fair bit of time to figure out, and then on top of that the build/class-path requirements for the Google Spreadsheets API is completely messed up.

But anyway, here's a short description of how I did it, notes, and the full code for the main activity.

1 - I am using a Nexus 4, so I set up my app to use the latest APIs possible (Android 4.2.2 on my system).

2 - The list of required JARs is crazy, and quite picky. Here's the screenshots of the ones I am using:

3 - I had to add the following permissions to my manifest file:

4 - And finally, here is the code itself to run the main activity. The basic application structure was just the one that is created by default when you create a new Android Application. The basic steps for listing the Spreadsheets I got from the Spreadsheets API Tutorial. I can't really remember where I learned the OAuth2.0 steps, but needless to say, I cobbled it together from several online sources.

This is awesome, thanks!.... I tried to add internet permission and got this , please help..." The tag requests a {@link #AndroidManifestPermission } that the containing package must be granted in order for it to operate correctly. "

I can't tell you thank you enough. I use a google spreadsheet for an expense tracker for my wife and I, and I've really been wanting to build an app to allow us to easily post data to it. However, I'm a beginner developer and I quickly realized that accessing the Spreadsheets API was way too complicated for someone of my experience level. But with your app to use as an example, I'm confident I'll be able to adapt your code for my needs.

If you have a donate link, I'll be happy to send you a small token of my appreciation.

Hey no problem at all. If you have any suggestions, or any questions that I might be able to help you with, just let me know. $$$ is not needed at all, just the thought that the hours I spent trying to figure this out might not have been in vain.

Hi Sir.I'm a newbie and want read values (as json) from my googleform which is published to web. I've tried you code but I'm getting "SystemUiHider cannot be resolved to a type" error. Do I need to use any API for that. Please make a reply...