2

我正在使用此Microsoft Graph 教程来查看使用 Android Studio 的 Microsoft 日历事件。我已经完成了教程,想知道如何创建事件。

我目前正在尝试使用Event对象来创建事件。我正在尝试使用此 GitHub 存储库中的以下代码:

Event event = new Event();
event.setSubject("Today's appointment");
event.setStart(dtz);
event.setImportance(Importance.High);
event.setIsReminderOn(true);
event.setReminderMinutesBeforeStart(15);

为此代码创建事件:

Event addedEvent = client.getMe().getCalendars().getById("Calendar").getEvents().add(event).get();

但似乎设置的功能不再可用,我找不到任何其他教程/资源。任何帮助将不胜感激。

谢谢你。

4

1 回答 1

1

您用于寻求帮助的 github 存储库不使用此处找到的 Java Graph SDK 。但是,如果您在第一次使用的 android 示例之上构建解决方案,下面的代码示例应该可以帮助您创建事件。

本质上,sdk 中的模型具有可以通过赋值直接修改的属性,我们使用post(event)POST http 方法将其发送过来。

Event event = new Event();
event.subject = "Let's go for lunch";
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "Does late morning work for you?";
event.body = body;
DateTimeTimeZone start = new DateTimeTimeZone();
start.dateTime = "2017-04-15T12:00:00";
start.timeZone = "Pacific Standard Time";
event.start = start;
DateTimeTimeZone end = new DateTimeTimeZone();
end.dateTime = "2017-04-15T14:00:00";
end.timeZone = "Pacific Standard Time";
event.end = end;
Location location = new Location();
location.displayName = "Harry's Bar";
event.location = location;

graphClient.me().events()
    .buildRequest()
    .post(event);

这个 github repo 也可以提供很大的帮助,因为它有许多很棒的片段 :) https://github.com/microsoftgraph/android-java-snippets-sample

于 2019-07-18T07:47:30.733 回答