java 使用适用于 Android 的 Google 文档和 Google 电子表格 API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6408580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 15:47:01  来源:igfitidea点击:

Using Google Docs and Google Spreadsheet APIs for Android

javaandroidgoogle-sheetsgoogle-appsgoogle-sheets-api

提问by gtdevel

I am planning on using the Google Documents List, and Google Documents Spreadsheet API's for uploading a database from my app to a spreadsheet online and then editing it.

我计划使用 Google 文档列表和 Google 文档电子表格 API 将数据库从我的应用程序上传到在线电子表格,然后对其进行编辑。

I just wanted to know if these API's would be the right approach for using Google docs as an online storage space for the data that I have collected in my app.

我只是想知道这些 API 是否是使用 Google 文档作为我在我的应用程序中收集的数据的在线存储空间的正确方法。

I was hoping that I could just get feedback from some of you who might have experience with this.

我希望我能从你们中的一些可能有这方面经验的人那里得到反馈。

The links for both API's are listed below:

下面列出了两个 API 的链接:

http://code.google.com/apis/documents/

http://code.google.com/apis/documents/

http://code.google.com/apis/spreadsheets/

http://code.google.com/apis/spreadsheets/

Thanks in advance!

提前致谢!

采纳答案by wescpy

(Dec 2016-Feb 2017)Various parts of this question are now out-of-date as: 1) GData APIs(including both the Documents List and Spreadsheets APIs) are the previous generation of Google APIs. While not all GData APIs have been deprecated, all modernGoogle APIsdo notuse the Google Data protocol; 2) the Google Documents List API has been replaced(and shut downin 2015) by the Google Drive API(mobile developers have a specific Google Drive Android API), 3) Google releaseda new Google Sheets API v4(not GData) in 2016, and 4) Android Studiois now the preferred IDE over Eclipse.

(2016 年 12 月至 2017 年 2 月)此问题的各个部分现已过时,因为:1) GData API(包括文档列表和电子表格 API)是上一代 Google API。虽然不是所有的GData API与已被否决,所有现代谷歌的API没有使用谷歌数据协议; 2) Google Documents List API 已被Google Drive API取代(并于 2015 年关闭)(移动开发人员具有特定的Google Drive Android API),3)Google在 2016 年发布了新的Google Sheets API v4(不是 GData) , 和 4)Android Studio现在是优于 Eclipse 的首选 IDE。

In order to use Google APIs, you need to get the Google APIs Client Library for Android(or for more general Java, the Google APIs Client Library for Java). Now for some examples... here's the Android quickstart code sampleas well as the more general Java Quickstart code samplefor the Sheets API. Can't hurt to pass along the JavaDocs reference for the Sheets APIeither.

为了使用 Google API,您需要获取适用于 AndroidGoogle API 客户端库(或者对于更通用的 Java,需要获取适用于 Java 的Google API 客户端库)。现在来看一些例子……这里是Android 快速入门代码示例以及更通用的针对 Sheets API 的Java 快速入门代码示例。传递Sheets APIJavaDocs 参考也无妨

If you're not "allergic" to Python, I've also made several videos with more "real-world" examples using the Sheets API (non-mobile though):

如果您对 Python 不“过敏”,我还制作了几个视频,其中包含使用 Sheets API 的更多“真实世界”示例(非移动设备):

The latest API provides features not available in older releases, namely giving developers programmatic document-oriented access to a Sheet as if you were using the user interface (create frozen rows, perform cell formatting, resizing rows/columns, adding pivot tables, creating charts, etc.) However, to perform file-level access such as imports & exports, you would use the Google Drive APIinstead -- for mobile, there's a specific Google Drive Android API.

最新的 API 提供了旧版本中不可用的功能,即为开发人员提供面向文档的编程访问工作表,就像您在使用用户界面一样(创建冻结行、执行单元格格式、调整行/列大小、添加数据透视表、创建图表等)但是,要执行文件级访问(例如导入和导出),您可以改用Google Drive API- 对于移动设备,有一个特定的Google Drive Android API

But based on your use-case, I don't believe you need the Drive API (nor the deprecated Documents List API) unless you need to perform file operations like searching or those I described just above. You can just use the Sheets API to "upload a database from your [Android] app to a spreadsheet online and then edit it." My one video above on "migrating SQL data to a Sheet" should give you enough pseudocode (that's what Python is, isn't it?) to write your app.

但是根据您的用例,我认为您不需要 Drive API(也不需要弃用的 Documents List API),除非您需要执行文件操作,例如搜索或我上面描述的那些操作。您只需使用 Sheets API 即可“将 [Android] 应用程序中的数据库上传到在线电子表格,然后进行编辑”。我上面关于“将 SQL 数据迁移到工作表”的一个视频应该为您提供足够的伪代码(这就是 Python,不是吗?)来编写您的应用程序。

To learn more about how to use Google APIs, check out the variety of Google developer videos (series 1and series 2) I'm producing (heads-up mostly Python or JavaScript).

要了解有关如何使用 Google API 的更多信息,请查看我正在制作的各种 Google 开发人员视频(系列 1系列 2)(主要是 Python 或 JavaScript)。

回答by ddewaele

For accessing Google APIs on the android platform, the Google APIs Client Library for Javais the way to go.

要在 android 平台上访问 Google API ,JavaGoogle API 客户端库是要走的路。

It includes sample appsfor the Documents and Spreadsheet APIs.

它包括文档和电子表格 API 的示例应用程序。

回答by user1299359

Personally I don't like Google's api lib for java. I honestly think you are better off using scribe and Hymanson to deserialize the feeds. We made a hello world. It includes calls with openid and oauth to spreadsheet feeds and deserialization template. Hope it helps.

我个人不喜欢 Google 的 java api lib。老实说,我认为您最好使用 scribe 和 Hymanson 来反序列化提要。我们创建了一个 hello world。它包括使用 openid 和 oauth 调用电子表格提要和反序列化模板。希望能帮助到你。

link

关联