2

For working with google spreadsheet api from android (2.2) - google suggests using google-api-java-client for android. For that you have to include 5 jars to your android application:

guava-r09.jar
google-http-client-extensions-android2-1.6.0-beta.jar
google-api-client-extensions-android2-1.6.0-beta.jar
google-http-client-1.6.0-beta.jar
google-api-client-1.6.0-beta.jar

and digging into google-api-java-client javadocs for fast-changing api.

Does it worth the effort? in term of android specifics and device fragmentation?

Isn't it reasonable to write your own simple http response parser or take small existing library like google-spreadsheet-lib-android ?

Thanks!

UPD: choosed google-api-java-client finally as it has all routine stuff (like parsing http, xml) out of box

yetanothercoder
  • 1,689
  • 4
  • 21
  • 43
  • Have wondered this myself. Were you able to get up and running fairly easy? I have searched for samples and not found _any_ – Patrick Jackson Feb 25 '12 at 18:08
  • 1
    Hi, Patrick - yes I checked in some samples you can find them [here](http://code.google.com/p/yetanothercoder/source/browse/android-tests/trunk/junit-src/ru/yetanothercoder/android/tests/SampleActivityTest.java). – yetanothercoder Feb 26 '12 at 14:10
  • The link appears to be gone. Is that sample still available/ – Patrick Jackson Oct 31 '12 at 14:42

1 Answers1

1

You can just use the gdata-java-client, which works on Android now that we've resolved an XML parsing issue.

Full Java samples are available here, but I've quoted the part about setting up the gdata-java-client.

To setup a development environment for working with the Spreadsheets API, perform the following steps.

  1. Download the latest gdata-src.java-*.zip file from the project's Downloads page. Replace * in this case with something like 1.46.0.

  2. Extract the ZIP file into a new directory.

    unzip gdata-src.java-1.46.0.zip -d ./gdata-java-client
    
  3. Copy the JARs from gdata-java-client/gdata/java/lib into a directory included in the application's classpath.

    cp gdata-java-client/gdata/java/lib/* /path/to/application/lib
    
  4. Copy the JARs from gdata-java-client/gdata/java/deps into the application's classpath.

    cp gdata-java-client/gdata/java/deps/* /path/to/application/lib
    
  5. Download the JavaMail API (version 1.4 or greater) from here. Extract the ZIP file and copy mail.jar to the application's classpath.

    unzip javamail1_4_4.zip -d javamail
    cp javamail/javamail-1.4.4/mail.jar /path/to/application/lib
    
  6. If using the Oracle JDK version 1.5, download the JavaBeans Activation Framework from here. Extract the ZIP file and copy activation.jar to the application's classpath.

    unzip jaf-1_1_1.zip -d jaf
    cp jaf/jaf-1.1.1/activation.jar /path/to/application/lib
    
  7. To implement any of the code discussed in this document, use the following class template.

    import com.google.gdata.client.authn.oauth.*;
    import com.google.gdata.client.spreadsheet.*;
    import com.google.gdata.data.*;
    import com.google.gdata.data.batch.*;
    import com.google.gdata.data.spreadsheet.*;
    import com.google.gdata.util.*;
    
    import java.io.IOException;
    import java.net.*;
    import java.util.*;
    
    public class MySpreadsheetIntegration {
      public static void main(String[] args)
      throws AuthenticationException, MalformedURLException,
      IOException, ServiceException {
    
        // Application code here
    
      }
    }
    

Once at this point, everything should be simple. Just make sure that you import the relevant JARs into Eclipse when working with your Android project. Adding JARs to Eclipse is discussed here.

Community
  • 1
  • 1
Vic Fryzel
  • 2,395
  • 16
  • 20
  • Vic, finally does gdata project support android or still: "Technology moves fast, and if your needs have grown in scope, then you might need the newer client library. For example, if you want to access API's from Android, google-api-java-client supports Android but gdata-java-client does not." (https://code.google.com/p/gdata-java-client/wiki/MigratingToGoogleApiJavaClient) – yetanothercoder Nov 21 '13 at 20:05