Best option for using the GData APIs on Android?

女生的网名这么多〃 提交于 2019-12-17 15:23:09

问题


What's the least painful and most size efficient way to use the Google Data APIs in an Android application?

After a few quick searches t seems that there is an android-gdata project on Google Code that seems to be the work of a single author. I didn't find any documentation for it and don't even know if it's production ready yet.

An older option, the com.google.wireless.gdata package seems to have been removed from the SDK. It's still available in the GIT repository.

Before I invest too much time with either approach I'd like to know which is the best supported and least painful.


回答1:


Please take a look at the Google API Client Library for Java which supports Android

It also supports new GData technologies like the recently announced partial response/update and JSON-C, both of which can be a dramatic improvement in efficiency on Android.

To start, please take a look at the Android Developer's Guide. Also, please look at the Android sample for Picasa Web Albums Data API, which demonstrates the ability create/update/delete a photo album and to upload a picture.

Full disclosure: I am an owner of the google-api-java-client project.




回答2:


I also looked at the google-code project and the git repo. I steered away from the google-code project due to the apparent baggage that came along in required projects. I ended up creating custom implementations as necessary to adapt the standard java API. You can find a rough description of my solution in the android-developers group. It is 4 short, easily tested classes




回答3:


Please try Google SpreadSheet API for Android

I am maintaining this project on Google Code, so if you face any problem, kindly let me know.

Cheers, Prasanta




回答4:


Here's some steps to getting the Google Docs api working with an Android Eclipse project.

Spoiler: it breaks (for me) on the SAX exception

1

Get the GData Java library (via the language guide)

2

Get the 3 jars from the Android Javamail port

3

Add the following jars in your lib folder, add them to the path using the context menu (Build path->Add)

  • activation.jar (javamail)
  • additionnal.jar (javamail)
  • mail.jar (javamail)
  • gdata-client-1.0.jar
  • gdata-client-meta-1.0.jar
  • gdata-core-1.0.jar
  • gdata-docs-3.0.jar
  • gdata-docs-meta-3.0.jar
  • gdata-gtt-2.0.jar
  • gdata-gtt-meta-2.0.jar
  • gdata-media-1.0.jar
  • google-collect-1.0-rc1.jar (from the deps folder of the gdata folder)
  • jsr305.jar3. (from the deps folder of the gdata folder)

4

Don't forget to add the INTERNET permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

5

Try out some example code:

DocsService client = new DocsService("myappname");
try
{
    client.setUserCredentials("username", "password");

    URL feedUri = new URL("https://docs.google.com/feeds/default/private/full/");
    DocumentListFeed feed = client.getFeed(feedUri, DocumentListFeed.class);

    TextView textView = (TextView) findViewById(R.id.textview);

    String text = ""; 
    for (DocumentListEntry entry : feed.getEntries())
    {
        text += entry.getTitle().getPlainText() + "\r\n";
    }

    textView.setText(text);
}
catch (AuthenticationException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}
catch (MalformedURLException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}
catch (IOException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}
catch (ServiceException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}

6

Accept defeat after 2 hours, with a SaxException from logcat:

WARN/XmlParser(1599): javax.xml.parsers.ParserConfigurationException:
org.xml.sax.SAXNotRecognizedException: http://xml.org/sax/features/external-parameter-entities
...
at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:68)

This last step causes a ServiceException.




回答5:


I used this API

I tried converting it to a .jar, but had problems. I found it easy to mark the project as a library project and then used it in my main project.



来源:https://stackoverflow.com/questions/524257/best-option-for-using-the-gdata-apis-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!