Note before I begin: The GData API does not work with Android. I am not sure what package you are using, but I used this one: http://code.google.com/p/android-gdocs- ... e/checkout
If there is another package you can use for GDocs stuff, please let me know. I would love to check it out!
Using java Syntax Highlighting
- // first, we will declare some variables
- // I will initialize on separate line, just so you can see what variables you need
- private SpreadsheetsClient sc;
- private ServiceDataClient sdc;
- private GDataParserFactory dspf;
- // now we will initalize these variables
- sdc = new ServiceDataClient("writely", "https", "https://docs.google.com");
- //sdc.setSSL(true); //set this if you want to use SSL
- dspf = new XmlSpreadsheetsGDataParserFactory(new AbstructParserFactory());
- sc = new SpreadsheetsClient(sdc, dspf);
- // now we will try to login
- try {
- sc.setUserCredentials(<put your username here>, <put your password here>);
- } catch (AuthenticationException e) {
- // TODO Auto-generated catch block
- Log.d("Authentication ERROR", "FAILED");
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
After this is done, go into your AndroidManifest.xml and add the following privileges:
Using xml Syntax Highlighting
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Just to clarify, I am not sure if BOTH of these are needed. I wrote this code a few weeks ago, and I can't remember why I have both. You definitely need the INTERNET permission, I am not sure about the WRITE_SETTINGS permission.
And that should be it!
Let me know if there are any problems with this code. I copied and pasted most of it directly from my project, which works.
Hope that helps!




