【问题标题】:Choose Non-default googlecalendar with google-java-client-api使用 google-java-client-api 选择非默认 googlecalendar
【发布时间】:2012-03-24 17:44:06
【问题描述】:

我想使用 google java 客户端 API 获取我的 GoogleAccount 中的所有日历。

在我的应用程序中,我希望用户可以选择在哪个日历中保存他的事件(不仅在默认情况下)。但因此我需要他们的 CalendarID。我不希望用户必须搜索他们的日历 ID 才能将它们手动写入应用程序。

是否可以在他的帐户中创建一个新日历,以便在这个新帐户中写入所有事件。

对不起,我的英语不好。

【问题讨论】:

  • 我解决了这个问题。新的帮助要好得多。
  • 新帮助是什么意思?你能尽快回答并自己接受这个答案吗?没关系,推荐。跟上。

标签: java android api events calendar


【解决方案1】:

是的,当然可以。您只需要知道要在其中保存新事件的 calendarId,并将它们与事件插入功能一起使用。

例如:

Event event = new Event();

event.setSummary("This is my Event");
event.setLocation("127.0.0.1 -- Home sweet Home!!");

ArrayList<EventAttendee> participants = new ArrayList<EventAttendee>();
participants .add(new EventAttendee().setEmail("member@domain.com"));
event.setAttendees(participants);

DateTime start = new DateTime(new Date(), TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));

DateTime end = new DateTime(new Date(startDate.getTime() + 3600000), TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));

Event createdEvent = service.events().insert("YourCalendarID", event).execute();

希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 2011-08-12
    • 1970-01-01
    • 2016-08-20
    • 2011-10-18
    • 1970-01-01
    相关资源
    最近更新 更多