java - 使用 google-java-client-api 选择非默认 googlecalendar

标签 java android api events calendar

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

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

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

抱歉我的英语不好。

最佳答案

当然可以。您只需要知道要在其中保存新事件的 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();

希望对您有所帮助!

关于java - 使用 google-java-client-api 选择非默认 googlecalendar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9597380/

相关文章:

java - ANT:如何将 "add"路径元素从一条路径转换为第二条路径?

java - 如何禁用(停用)Spoon 登录?

Android:将图像保存到 Sqlite 数据库中

javax.ws.rs.core.Cookie vs javax.ws.rs.core.NewCookie ,有什么区别?

c++ - GD 图片库 : Range of colour component arguments for TrueColor images

java - 已订购 SQlite 数据库(基于 XML feed)

java - 在 OS X Eclipse 上使用 Maven 安装 Mahout

android - Cordova添加平台android错误

android - React Native 安全问题

javascript - D3.js 图表随机数据或天气 API