我已按照https://developers.google.com/google-apps/calendar/v3/reference/events/insert#examples插入新事件,但在此行遇到问题:
event = service.events().insert(calendarId, event).execute();
当我调试到上面的行时,应用程序强制关闭,我不知道问题所在...
最佳答案
就我而言,问题也是范围,所以对于那些不知道怎么做的人来说,解决方案是:
改变这个
private static final String[] SCOPES = { CalendarScopes.CALENDAR_READONLY };
为了这
private static final String[] SCOPES = { CalendarScopes.CALENDAR };
现在您可以初始化凭据
// Initialize credentials and service object.
mCredential = GoogleAccountCredential.usingOAuth2(
getApplicationContext(), Arrays.asList(SCOPES))
.setBackOff(new ExponentialBackOff());