Google Calendar API:新的事件属性

发布于 2024-11-04 11:44:44 字数 1063 浏览 4 评论 0原文

我正在开发一个 Android 应用程序,它使用 GData API for Google 连接到 Google 日历Java 中的日历。到目前为止,我已经成功创建了事件,但我只能设置标题、描述和时间。

有谁知道我在哪里可以找到包含我可以为事件设置的所有参数的参考或样本?

我给你留下了一些我迄今为止所取得的成就的代码。

CalendarService calendarService = new CalendarService("CalendarAPP");
calendarService.setUserCredentials(<username>, <password>);
URL postUrl = new URL("https://www.google.com/calendar/feeds/<GMAIL ACCOUNT>/private/full");
CalendarEventEntry myEntry = new CalendarEventEntry();

myEntry.setTitle(new PlainTextConstruct("Tennis with Beth"));
myEntry.setContent(new PlainTextConstruct("Meet for a quick lesson."));

DateTime startTime = DateTime.now();
DateTime endTime = DateTime.now();
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);

CalendarEventEntry insertedEntry = connection.getCalendarService().insert(postUrl, myEntry);

提前致谢。

米基万。

I'm developing an Android APP that connects to Google Calendar using GData API for Google Calendar in Java. So far I've managed to create events but I could only set the title, description and time.

Does anybody know where I can find a reference or a sample with all the parameters I can set to an event?

I leave you some code of what I've achieved so far.

CalendarService calendarService = new CalendarService("CalendarAPP");
calendarService.setUserCredentials(<username>, <password>);
URL postUrl = new URL("https://www.google.com/calendar/feeds/<GMAIL ACCOUNT>/private/full");
CalendarEventEntry myEntry = new CalendarEventEntry();

myEntry.setTitle(new PlainTextConstruct("Tennis with Beth"));
myEntry.setContent(new PlainTextConstruct("Meet for a quick lesson."));

DateTime startTime = DateTime.now();
DateTime endTime = DateTime.now();
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);

CalendarEventEntry insertedEntry = connection.getCalendarService().insert(postUrl, myEntry);

Thanks in advance.

Mikywan.

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

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

发布评论

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

评论(1

清风夜微凉 2024-11-11 11:44:44

GData for Google Calendar 非常棒。对于您可能想要设置或获取的每个属性,都定义了一个 Getter 和一个 Setter。您只需在事件条目上查找适合您想要访问的数据的 setter/getter 即可。

我留下了一个示例,说明如何在控制台上显示几乎所有您可能想要的数据。

享受!

private static void showCalendarEventEntry(CalendarEventEntry entry) {
    assert entry != null;
    System.out.println("-------------------------------------------");
    System.out.println("START showCalendarEventEntry");
    System.out.println("");
    System.out.println("ID: " + entry.getId());
    System.out.println("TITLE: "+entry.getTitle().getPlainText());
    System.out.println("DESCRIPTION: "+entry.getPlainTextContent());
    System.out.println("LOCATION: "+entry.getLocations().get(0).getValueString());

    System.out.println("");
    System.out.println("TIMES");
    if (entry.getTimes().size() > 0) {
        When eventTimes = entry.getTimes().get(0);
        if (eventTimes.getStartTime().isDateOnly()) {
            System.out.println("\tWHEN: ALL DAY");
        } else {
            System.out.println("\tWHEN: TIME");
        } 

        if (entry.getRecurrence() != null)
            System.out.println("\tRECURRENCE: "+entry.getRecurrence().toString()); 

        System.out.println("\tSTART TIME: "+eventTimes.getStartTime());
        System.out.println("\tEND TIME: "+eventTimes.getEndTime());
    }

    System.out.println("");
    System.out.println("PARTICIPANTS");
    System.out.println("\t"+(entry.getParticipants().size()) + " PARTICIPANTS");
    if (entry.getParticipants().size() > 0){

        for (int i=0; i<entry.getParticipants().size(); i++) {
            EventWho participant = entry.getParticipants().get(i);
            System.out.println("\t\tPARTICIPANT "+participant.getValueString());
            System.out.println("\t\t\tTYPE: "+participant.getAttendeeType());
            System.out.println("\t\t\tSTATUS: "+participant.getAttendeeStatus());
        }
        if (entry.isGuestsCanInviteOthers())
            System.out.println("\tGUESTS CAN INVITE OTHERS: ");
        if (entry.isGuestsCanModify())
            System.out.println("\tGUESTS CAN MODIFY");
        if (entry.isGuestsCanSeeGuests())
            System.out.println("\tGUESTS CAN SEE GUESTS");
    } 

    //REMINDERS
    System.out.println("");
    System.out.println("REMINDERS");
    System.out.println("\t"+entry.getReminder().size()+" REMINDERS");
    if (entry.getReminder().size() > 0) {
        for (int i=0; i<entry.getReminder().size(); i++) {
            Reminder reminder = entry.getReminder().get(i);
            System.out.println("\t\tREMINDER "+i);
            System.out.println("\t\t\tMETHOD: "+reminder.getMethod().toString());
            System.out.println("\t\t\tDAYS: "+reminder.getDays());
            System.out.println("\t\t\tHOURS: "+reminder.getHours());
            System.out.println("\t\t\tMINUTES: "+reminder.getMinutes());                
        }
    }

    //VISIBILITY
    System.out.println("");
    System.out.println("VISIBILITY: "+entry.getVisibility().getValue());

    System.out.println("");
    System.out.println("END showCalendarEventEntry");
    System.out.println("-------------------------------------------");
}

GData for Google Calendar it's pretty damn good. For every property you may want to set or get, there is a Getter and a Setter defined. You just have to look for the setter/getter on the event entry that suits the data you want access.

I leave an example of how to show on the console almost all the data you may want to.

Enjoy!

private static void showCalendarEventEntry(CalendarEventEntry entry) {
    assert entry != null;
    System.out.println("-------------------------------------------");
    System.out.println("START showCalendarEventEntry");
    System.out.println("");
    System.out.println("ID: " + entry.getId());
    System.out.println("TITLE: "+entry.getTitle().getPlainText());
    System.out.println("DESCRIPTION: "+entry.getPlainTextContent());
    System.out.println("LOCATION: "+entry.getLocations().get(0).getValueString());

    System.out.println("");
    System.out.println("TIMES");
    if (entry.getTimes().size() > 0) {
        When eventTimes = entry.getTimes().get(0);
        if (eventTimes.getStartTime().isDateOnly()) {
            System.out.println("\tWHEN: ALL DAY");
        } else {
            System.out.println("\tWHEN: TIME");
        } 

        if (entry.getRecurrence() != null)
            System.out.println("\tRECURRENCE: "+entry.getRecurrence().toString()); 

        System.out.println("\tSTART TIME: "+eventTimes.getStartTime());
        System.out.println("\tEND TIME: "+eventTimes.getEndTime());
    }

    System.out.println("");
    System.out.println("PARTICIPANTS");
    System.out.println("\t"+(entry.getParticipants().size()) + " PARTICIPANTS");
    if (entry.getParticipants().size() > 0){

        for (int i=0; i<entry.getParticipants().size(); i++) {
            EventWho participant = entry.getParticipants().get(i);
            System.out.println("\t\tPARTICIPANT "+participant.getValueString());
            System.out.println("\t\t\tTYPE: "+participant.getAttendeeType());
            System.out.println("\t\t\tSTATUS: "+participant.getAttendeeStatus());
        }
        if (entry.isGuestsCanInviteOthers())
            System.out.println("\tGUESTS CAN INVITE OTHERS: ");
        if (entry.isGuestsCanModify())
            System.out.println("\tGUESTS CAN MODIFY");
        if (entry.isGuestsCanSeeGuests())
            System.out.println("\tGUESTS CAN SEE GUESTS");
    } 

    //REMINDERS
    System.out.println("");
    System.out.println("REMINDERS");
    System.out.println("\t"+entry.getReminder().size()+" REMINDERS");
    if (entry.getReminder().size() > 0) {
        for (int i=0; i<entry.getReminder().size(); i++) {
            Reminder reminder = entry.getReminder().get(i);
            System.out.println("\t\tREMINDER "+i);
            System.out.println("\t\t\tMETHOD: "+reminder.getMethod().toString());
            System.out.println("\t\t\tDAYS: "+reminder.getDays());
            System.out.println("\t\t\tHOURS: "+reminder.getHours());
            System.out.println("\t\t\tMINUTES: "+reminder.getMinutes());                
        }
    }

    //VISIBILITY
    System.out.println("");
    System.out.println("VISIBILITY: "+entry.getVisibility().getValue());

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