来自 android 的 google 电子表格 api:google-api-java-client 还是手工制作?

发布于 2024-12-22 18:34:24 字数 801 浏览 3 评论 0原文

要使用 Android (2.2) 中的 google 电子表格 api - google 建议使用 google-适用于 Android 的 api-java-client。为此,您必须在 Android 应用程序中包含 5 个 jar:

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

并深入研究 google-api-java-client javadocs 以获取快速变化的 api。

值得付出努力吗?就 Android 细节和设备碎片而言?

编写自己的简单 http 响应解析器或采用小型现有库(例如 google-spreadsheet-lib-android

谢谢!

UPD:最终选择了 google-api-java-client,因为它具有开箱即用的所有常规内容(例如解析 http、xml)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的位置 2024-12-29 18:34:24

您只需使用适用于 Android 的 gdata-java-client现在我们已经解决了 XML 解析问题。

完整的 Java 示例可在此处获取,但我引用了有关设置的部分gdata-java-客户端。

要设置使用 Spreadsheets API 的开发环境,请执行以下步骤。

  1. 从项目的下载最新的 gdata-src.java-*.zip 文件
    下载页面。在本例中将 * 替换为 1.46.0 之类的内容。

  2. 将 ZIP 文件解压到新目录中。

    解压 gdata-src.java-1.46.0.zip -d ./gdata-java-client
    
  3. 复制 JAR
    从 gdata-java-client/gdata/java/lib 进入包含在
    应用程序的类路径。

    cp gdata-java-client/gdata/java/lib/* /path/to/application/lib
    
  4. 复制
    将 gdata-java-client/gdata/java/deps 中的 JAR 放入应用程序的
    类路径。

    cp gdata-java-client/gdata/java/deps/* /path/to/application/lib
    
  5. 此处下载 JavaMail API(版本 1.4 或更高版本) 。提炼
    ZIP 文件并将 mail.jar 复制到应用程序的类路径。

    解压 javamail1_4_4.zip -d javamail
    cp javamail/javamail-1.4.4/mail.jar /path/to/application/lib
    
  6. 如果使用
    Oracle JDK 版本 1.5,下载 JavaBeans 激活框架
    来自此处。解压ZIP文件并将activation.jar复制到
    应用程序的类路径。

    解压 jaf-1_1_1.zip -d jaf
    cp jaf/jaf-1.1.1/activation.jar /path/to/application/lib
    
  7. 实现中讨论的任何代码
    本文档,使用以下类模板。

    导入 com.google.gdata.client.authn.oauth.*;
    导入 com.google.gdata.client.spreadsheet.*;
    导入 com.google.gdata.data.*;
    导入 com.google.gdata.data.batch.*;
    导入 com.google.gdata.data.spreadsheet.*;
    导入 com.google.gdata.util.*;
    
    导入java.io.IOException;
    导入java.net.*;
    导入 java.util.*;
    
    公共类 MySpreadsheetIntegration {
      公共静态无效主(字符串[]参数)
      抛出 AuthenticationException、MalformedURLException、
      IOException,服务异常 {
    
        // 这里是应用程序代码
    
      }
    }
    

一旦到了这一步,一切就应该很简单了。只需确保在处理 Android 项目时将相关 JAR 导入到 Eclipse 中即可。 此处讨论了将 JAR 添加到 Eclipse。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文