如何使用Google Calendar API v3更改日历的颜色?
问题描述:
我有此代码段,这与编辑谷歌日历API V3日历摘要:如何使用Google Calendar API v3更改日历的颜色?
com.google.api.services.calendar.model.Calendar calendar = mService.calendars().get(CalendarActivity.this.editid).execute();
calendar.setSummary(CalendarActivity.this.title);
com.google.api.services.calendar.model.Calendar updatedCalendar = mService.calendars().update(calendar.getId(), calendar).execute();
但如何改变日历的颜色?
没有setColorId()
方法。不知道该怎么做。
答
您可以使用此一:
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.CalendarListEntry;
// ...
// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
.setApplicationName("applicationName").build();
// Retrieve the calendar list entry
CalendarListEntry calendarListEntry = service.calendarList().get("calendarId").execute();
// Make a change
calendarListEntry.setColorId("0");
// Update the altered entry
CalendarListEntry updatedCalendarListEntry =
service.calendarList().update(calendarListEntry.getId(), calendarListEntry).execute();
System.out.println(updatedCalendarListEntry.getEtag());
https://developers.google.com/google-apps/calendar/v3/reference/calendarList/update
因此,有没有可能改变日历的颜色? – ubik