谷歌日历:如何在 Android 上访问它

发布于 2024-10-26 12:12:24 字数 646 浏览 0 评论 0原文

现在在 Android 上访问谷歌日历的最佳方式是什么?

我找到了以下方法:

google-api-java-client - 这只是一个 alpha 版本。身份验证、获取日历列表有效,但更新日历在示例中崩溃。 +无论如何,没有文档和错误的示例代码。

黑客攻击逆向工程 -听起来也很糟糕,(可能)不是面向未来的。

Google 数据 api - 就目前而言我知道,它不支持/在 Android 上运行。

有没有我错过的替代方案?有没有可行的例子?

What would be the best way to acces the google calendar on android right now?

I found the following ways:

google-api-java-client - It's only an alpha. Authenticating, getting calendar list works, but updating calendar crashes in sample. +no documentation and bad sample codes anyway.

hackity hack reverse engeneering - Sounds bad, also, (propably) not futureproof.

Google data api - As far as I know, it does not support/work on android.

Are there any alternatives that I have missed? Are there any working examples out there?

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

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

发布评论

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

评论(4

装纯掩盖桑 2024-11-02 12:12:24

我最近为此使用了 SignPost。它处理 OAuth,您可以使用它来签署 HTTP 请求以获取数据或将数据发布到您的日历。我在让 Google 的 Java API 与 Android 配合使用时遇到了麻烦,因为我认为它依赖于 Android 中不一定存在的 Java API。

要提出请求,您可以参考此页面:http://code .google.com/apis/calendar/data/2.0/developers_guide_protocol.html

I recently used SignPost for this. It handles OAuth, and you can use it to sign your HTTP requests to get or post data to your calendars. I had trouble getting Google's Java API to work with Android since I think it relies on Java APIs that are not necessarily present in Android.

To make your requests, you can refer to this page: http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html

友欢 2024-11-02 12:12:24

您是否看过数据 API 开发人员指南:Java?如果情况允许,您还可以直接使用 HTTP 请求/响应 Java API 不支持您想要/需要的内容。

我个人没有使用过 Java API,但我直接使用过 HTTP,发现它非常简单。

Have you looked at the Data API Developer's Guide: Java? You can also work directly with HTTP request/response, if things you want/need aren't supported in the Java API.

I haven't personally used the Java API, but I have worked directly with HTTP, and found it to be pretty straightforward.

债姬 2024-11-02 12:12:24

我认为这是一个众所周知的问题,但还不是很清楚。查看提供的所有问题和答案,似乎您有两个选择:

  • 使用您在答案中引用的技巧(根本不建议,因为正如您所说,不能保证相同的技巧将来会起作用)。为了使其即使在 froyo 下也能正常工作,已进行了一些更新,请参阅 这里

  • 使用此http://code.google.com/p/google -api-java-client/。引用网站上的项目描述

该库由 Google 编写,是一个
灵活、高效、强大的 Java
用于访问任何客户端库
网络上基于 HTTP 的 API。它是
推荐的访问库
基于 REST 的 Google API 或
JSON-RPC。

`

I think that this is a well known issue, but not so well clear yet. Looking at all the questions and answer provided it seems that you have two options:

  • Use the hacks you were refering in your answer (not suggested at all, because as you said there is no guarantee that the same trick will work in future). Some updates have been made in order to make it works even under froyo, see here.

  • Use this http://code.google.com/p/google-api-java-client/. Quoting from the project description on the website

Written by Google, this library is a
flexible, efficient, and powerful Java
client library for accessing any
HTTP-based API's on the web. It is the
recommended library for accessing
Google API's based on REST or
JSON-RPC.

`

聽兲甴掵 2024-11-02 12:12:24

包含来自 gdata api 的这些(Calendar-2.1、client 1.0、core 1.0)jar 文件,并在我们的应用程序中包含两个外部 jar 文件。这两个文件(guava-11.0.2 和 jsr305 )可在 gdata 的 deps 文件夹中

找到从日历中检索事件的代码

在全局范围内声明您的日历 ID 和密码

您可以使用 facebook.com/rajivbawa22 上的此地址在 facebook 上与我联系以获取更多教程,

    String userName = "[email protected]"; // put here your gmail id 

String userPassword = "12345-example ";// put here your gmail password 

但请确保您在 Gmail 中也有帐户就像在谷歌日历中一样,

尝试{

        CalendarService myService = new CalendarService("com.demo.calendar");

        myService.setUserCredentials(userName, userPassword);
        // Send the request and print the response
        URL feedUrl = new URL(
                "https://www.google.com/calendar/feeds/"+userName+"/private/full");
        // "https://www.google.com/calendar/feeds/default/owncalendars/full");
        Log.e("", "Calendar1========");
        CalendarFeed resultFeed = myService.getFeed(feedUrl,
                CalendarFeed.class);
        Log.e("", "Calendar2*********" + resultFeed);
        for (int i = 0; i < resultFeed.getEntries().size(); i++) {

            Log.e("", "========" + resultFeed.getEntries().size());

            CalendarEntry entry = resultFeed.getEntries().get(i);

            Log.e("", "**********" + entry.getTitle().getPlainText());

        }
    } catch (Exception e) {

        e.printStackTrace();
    }

查看日志中的结果并提供反馈

Include these(Calendar-2.1,client 1.0,core 1.0) jar files from gdata api and include two external jar files in our application.. Those two files (guava-11.0.2 and jsr305 ) are available in deps folder of gdata

and this code for retrive events from calendar

Declare globally your calendar id and password

you can reach to me on facebook by using this address on facebook.com/rajivbawa22 for more tutorials

    String userName = "[email protected]"; // put here your gmail id 

String userPassword = "12345-example ";// put here your gmail password 

but make sure you have account in gmail as well as in google calendar

try {

        CalendarService myService = new CalendarService("com.demo.calendar");

        myService.setUserCredentials(userName, userPassword);
        // Send the request and print the response
        URL feedUrl = new URL(
                "https://www.google.com/calendar/feeds/"+userName+"/private/full");
        // "https://www.google.com/calendar/feeds/default/owncalendars/full");
        Log.e("", "Calendar1========");
        CalendarFeed resultFeed = myService.getFeed(feedUrl,
                CalendarFeed.class);
        Log.e("", "Calendar2*********" + resultFeed);
        for (int i = 0; i < resultFeed.getEntries().size(); i++) {

            Log.e("", "========" + resultFeed.getEntries().size());

            CalendarEntry entry = resultFeed.getEntries().get(i);

            Log.e("", "**********" + entry.getTitle().getPlainText());

        }
    } catch (Exception e) {

        e.printStackTrace();
    }

see result in logs and give yours feedbacks

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