Try checking the Google Sample for Calendar API in Android , this explains the basic functions like adding a calendar, editing, update and delete calendar.
(尝试检查Android中的Google Sample for Calendar API ,这说明了添加日历,编辑,更新和删除日历等基本功能。)
Also I've found more detailed tutorials How to integrate google calendar api in android application and Android Tutorial–Programming with Calendar that will help you with code implementation of adding events using your app. (另外,我还找到了更详细的教程, 如何将google calendar API集成到android应用程序中,以及如何将 Android日历编程与Calendar 集成 在一起 ,这将帮助您实现使用应用添加事件的代码实现。)
Add event code:
(添加事件代码:)
void insertEvent(String summary, String location, String des, DateTime startDate, DateTime endDate, EventAttendee[] eventAttendees) throws IOException {
Event event = new Event()
.setSummary(summary)
.setLocation(location)
.setDescription(des); EventDateTime start = new EventDateTime()
.setDateTime(startDate)
.setTimeZone(“America/Los_Angeles”);
event.setStart(start); EventDateTime end = new EventDateTime()
.setDateTime(endDate)
.setTimeZone(“America/Los_Angeles”);
event.setEnd(end); String[] recurrence = new String[] {“RRULE:FREQ=DAILY;COUNT=1”};
event.setRecurrence(Arrays.asList(recurrence)); event.setAttendees(Arrays.asList(eventAttendees)); EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod(“email”).setMinutes(24 * 60),
new EventReminder().setMethod(“popup”).setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders); String calendarId = “primary”;
//event.send
if(mService!=null)
mService.events().insert(calendarId, event).setSendNotifications(true).execute();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…