如何通过 Android 应用程序查看公共 Google 日历 [英] How to view a public Google Calendar via an Android Application

查看:22
本文介绍了如何通过 Android 应用程序查看公共 Google 日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我一定已经完成了基于 Google 日历的 Stack Overflow 问题,但一直没有运气.我已经尝试了几个小时,但几乎没有结果.

I must've gone through ever Stack Overflow question based on the Google Calendar so far with no luck what so ever. I've been trying this for hours now and got little to no results at all.

我是一名非常新的 Java 和 Android 程序员,在该领域之外的经验很少.基本上,我遇到的主要问题是查看其他用户设置为公开的 Google 日历.

I'm a pretty new programmer with Java and Android, with quite little experience out of the field as it is. Basically the main problem I am having is with viewing another user's Google Calendar which is set to public.

目前,我已经通过 Google 教程和其他网站设法显示了日历,这非常简单.它只会加载并显示当前用户的日历.这实际上可以通过(在布局中使用一个简单的按钮)来完成.

At the moment, from the Google tutorials and other sites I've managed to get the calendar showing, which is pretty simple enough. It'll just load up and show the current user's calendar. Which can literally be done with (with a simple button in the layout).

    public void onClick(View view) {
    // A date-time specified in milliseconds since the epoch.
    long startMillis = System.currentTimeMillis();

    Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
    builder.appendPath("time");
    ContentUris.appendId(builder, startMillis);
    Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
    startActivity(intent);
}

显然这不会传递任何公共帐户的用户数据或任何东西,我一直在阅读日历提供程序 Google 教程中的开发人员指南.我试图设置帐户详细信息,但它从来没有奏效.我曾尝试将其作为同步适配器来实现,但老实说,我只知道我做得不对.我不知道我是否真的需要使用同步适配器,因为我想要做的只是从字面上查看事件,而不是修改任何内容或更新任何内容.

Obviously this doesn't pass in any user data for the public account or anything, I've been reading through the Calendar Provider Developer guides within the Google tutorials. I've tried to set up the account details thing, but it just never works. I've tried to do it as a Sync Adapter, but honestly I just know I'm not doing it right. I don't know if I really even need to use a Sync Adapter as all I want to do is literally see the events, not modify anything or update anything.

我正在使用 API 14+ 并希望使用日历提供程序等.它看起来很简单,但几天来我一直在抨击它并投入了大量时间,似乎我所做的一切都不起作用.至少我有某种日历开放,但这不是我想要的.

I am using API 14+ and want to user the Calendar Provider etc. It looks simple enough but I've been bashing my head against this for a few days and put a lot of hours into it and seemingly nothing I do works. At least I've got some sort of calendar opening but it's not what I want.

这完全取决于同步适配器吗?如果是这样,我将如何调用日历?另一个类似的问题

Is it all just down to the sync adapter? If so how will I be able to call a calendar? Another question similar had

private static Uri buildCalUri() {
return CalendarContract.Calendars.CONTENT_URI
        .buildUpon()
        .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
        .appendQueryParameter(Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
        .appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
        .build();

}

我希望这与我需要的类似,但我不确定.在开发者教程中,如果帐户不在设备上,ACCOUNT_TYPE_LOCAL 很重要

I'm hoping this is something similar to what I need but I'm very unsure. In the developer tutorial ACCOUNT_TYPE_LOCAL was important if the account wasn't on the device

任何帮助将不胜感激!

推荐答案

如果您希望将公共 Google 日历 (www.google.com/calendar) 与您的 Android 应用程序集成,则必须使用 Google 日历 API.

If you are looking to integrate the public Google Calendar (www.google.com/calendar) with your Android Application, you have to use the Google Calendar API.

最简单的方法是从这里下载 Google 日历客户端库和然后使用此处的 API 参考.在客户端库页面中,您想要下载Google APIs Client Library for Java (rc)"包以集成到您的 Android 应用程序中.

The easiest method would be download the Google Calendar Client Library from here and then use the API Reference here. In the Client Library Page, you want to download "Google APIs Client Library for Java (rc)" package to integrate into your Android App.

您首先需要转到 API Console 以创建具有日历 API 访问权限的应用.

You will first need to go to API Console to create an App with Calendar API Access .

如果你不想使用原生库,你甚至可以使用 REST API(使用 HTTP GET & POST 命令),示例应用程序在这里

If you do not want to use the native library, you can even do it using REST API (use HTTP GET & POST Commands), example App here

希望这会有所帮助.

这篇关于如何通过 Android 应用程序查看公共 Google 日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆