gpt4 book ai didi

java - 将与会者添加到 android 日历事件

转载 作者:太空狗 更新时间:2023-10-29 15:09:34 25 4
gpt4 key购买 nike

我已经设法将“主要”信息传递到日历 Intent 中...

但是,当我尝试将与会者添加到 Intent 时,他们没有被插入。这是代码

        startCalIntent =  new Intent(Intent.ACTION_EDIT);
startCalIntent.setType("vnd.android.cursor.item/event");

startCalIntent.putExtra(Events.TITLE, title);
startCalIntent.putExtra(Events.EVENT_LOCATION, location);
startCalIntent.putExtra(Events.DESCRIPTION, details);
startCalIntent.putExtra(Events.ORGANIZER, organiser);
startCalIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, splitDateTime(date, startTime));
startCalIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, splitDateTime(date, endTime));
startCalIntent.putExtra(Events.EVENT_TIMEZONE, "Europe/London");


startCalIntent.putExtra(Attendees.HAS_ATTENDEE_DATA, "1");
startCalIntent.putExtra(Attendees.ATTENDEE_NAME, "DAVE");//<---NOT WORKING

startActivity(startCalIntent);

最佳答案

您不能在创建 Activity 期间添加与会者。您需要 Event_ID 才能对事件进行另一次更新,例如添加剩余人员或与会者。

Note: See how this example captures the event ID after the event is created. This is the easiest way to get an event ID. You often need the event ID to perform other calendar operations—for example, to add attendees or reminders to an event.

来源:Android developer

您可以使用 Android 开发人员提供的代码:

long eventID = 202;
...
ContentResolver cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(Attendees.ATTENDEE_NAME, "Trevor");
values.put(Attendees.ATTENDEE_EMAIL, "trevor@example.com");
values.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ATTENDEE);
values.put(Attendees.ATTENDEE_TYPE, Attendees.TYPE_OPTIONAL);
values.put(Attendees.ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_INVITED);
values.put(Attendees.EVENT_ID, eventID);
Uri uri = cr.insert(Attendees.CONTENT_URI, values);

希望对您有所帮助;

关于java - 将与会者添加到 android 日历事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18102438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com