如何将要同步的电子邮件 ID 传递到 Android 中的创建事件日历中?

发布于 2024-12-04 22:48:16 字数 827 浏览 1 评论 0原文

在 android 中,我们通过意图以编程方式插入事件。我们插入标题、描述和时间。但没有找到将与会者邮件 ID 和收件人邮件 ID 插入日历事件的键。如果不可能,为什么这不可能?如果可能,我该如何实现?

问题简要说明: 如何通过电子邮件将要同步的日历的邮件ID传递到创建事件中? 我有一个微调器,显示要同步的帐户列表。现在,像往常一样传递标题、描述以在日历应用程序中创建事件,我使用以下代码。

ContentValues values = new ContentValues();
    values.put("calendar_id", 1);
    values.put("title", title1);
    values.put("allDay", 0);
    values.put("dtstart", settime); // event starts at 11 minutes from now
    values.put("dtend", cal.getTimeInMillis()+60*60*1000); // ends 60 minutes from now
    values.put("description", desc1);
    values.put("???????", mail_id);
    values.put("???????", participant_mail_id);
    values.put("visibility", 0);
    values.put("hasAlarm", 1);
    event = cr.insert(EVENTS_URI, values);

我应该使用什么来传递插入电子邮件 ID 和参与者 ID 的密钥?非常感谢任何帮助。我的屏幕截图如下。

In android we insert an event programmatically through intent. we insert title, description and time . But there is no key found to insert attendee mail id and recipient mail id into a calendar event. If it is impossible, Why is this not possible & If Possible , How do i achieve it?

Brief Explanation of question:
How to pass the mail id of the calendar that to be synchronized into the create event through email?
I have a spinner that shows the list of accounts to be synchronized . Now, as usual passing title,description to create event in calendar application, i use following code.

ContentValues values = new ContentValues();
    values.put("calendar_id", 1);
    values.put("title", title1);
    values.put("allDay", 0);
    values.put("dtstart", settime); // event starts at 11 minutes from now
    values.put("dtend", cal.getTimeInMillis()+60*60*1000); // ends 60 minutes from now
    values.put("description", desc1);
    values.put("???????", mail_id);
    values.put("???????", participant_mail_id);
    values.put("visibility", 0);
    values.put("hasAlarm", 1);
    event = cr.insert(EVENTS_URI, values);

What should i use to pass the key to insert email id and participant id? Any Help is really appreciated. My screen shot goes below.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流星番茄 2024-12-11 22:48:16

日历提供程序自 ICS(API 级别 - 14)起是公开的。更多信息此处

要添加与会者,您需要事件 ID,因此您需要先添加事件。

API 级别 >=14 的示例:

ContentResolver cr = getContentResolver();

// add event
ContentValues values = new ContentValues();
values.put(Events.DTSTART, startMillis);
values.put(Events.DTEND, endMillis);
values.put(Events.TITLE, "Jazzercise");
values.put(Events.DESCRIPTION, "Group workout");
values.put(Events.CALENDAR_ID, calID);
values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
Uri uri = cr.insert(Events.CONTENT_URI, values);

// get the event ID that is the last element in the Uri
long eventID = Long.parseLong(uri.getLastPathSegment());

// add attendee
values = new ContentValues();
values.put(Attendees.ATTENDEE_NAME, "Trevor");
values.put(Attendees.ATTENDEE_EMAIL, "[email protected]");
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);
cr.insert(Attendees.CONTENT_URI, values);

API 级别 <14 的示例14:

String calendarLocation;
// set calendar URI (depends on api level)
if (Build.VERSION.SDK_INT >= 8) {
    calendarLocation = "content://com.android.calendar/"; 
} else {
    calendarLocation = "content://calendar/";
}

// URIs for events and attendees tables
Uri EVENTS_URI = Uri.parse(calendarLocation + "events");
Uri ATTENDEES_URI = Uri.parse(calendarLocation + "attendees");

ContentResolver cr = getContentResolver();

// add event
ContentValues values = new ContentValues();
values.put("dtstart", startMillis);
values.put("dtend", endMillis);
values.put("title", "Jazzercise");
values.put("description", "Group workout");
values.put("calendar_id", calID);
values.put("eventTimezone", "America/Los_Angeles");
Uri uri = cr.insert(EVENTS_URI, values);

// get the event ID that is the last element in the Uri
long eventID = Long.parseLong(uri.getLastPathSegment());

// add attendee
values = new ContentValues();
values.put("attendeeName", "Trevor");
values.put("attendeeEmail", "[email protected]");
values.put("attendeeRelationship", 1);
values.put("attendeeType", 2);
values.put("attendeeStatus", 3);
values.put("event_id", eventID);
cr.insert(ATTENDEES_URI, values);

Calendar Provider is public since ICS (API Level - 14). More info here

To add attendees you need the event id, so you need to add event first.

Example for API level >=14:

ContentResolver cr = getContentResolver();

// add event
ContentValues values = new ContentValues();
values.put(Events.DTSTART, startMillis);
values.put(Events.DTEND, endMillis);
values.put(Events.TITLE, "Jazzercise");
values.put(Events.DESCRIPTION, "Group workout");
values.put(Events.CALENDAR_ID, calID);
values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
Uri uri = cr.insert(Events.CONTENT_URI, values);

// get the event ID that is the last element in the Uri
long eventID = Long.parseLong(uri.getLastPathSegment());

// add attendee
values = new ContentValues();
values.put(Attendees.ATTENDEE_NAME, "Trevor");
values.put(Attendees.ATTENDEE_EMAIL, "[email protected]");
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);
cr.insert(Attendees.CONTENT_URI, values);

Example for API level < 14:

String calendarLocation;
// set calendar URI (depends on api level)
if (Build.VERSION.SDK_INT >= 8) {
    calendarLocation = "content://com.android.calendar/"; 
} else {
    calendarLocation = "content://calendar/";
}

// URIs for events and attendees tables
Uri EVENTS_URI = Uri.parse(calendarLocation + "events");
Uri ATTENDEES_URI = Uri.parse(calendarLocation + "attendees");

ContentResolver cr = getContentResolver();

// add event
ContentValues values = new ContentValues();
values.put("dtstart", startMillis);
values.put("dtend", endMillis);
values.put("title", "Jazzercise");
values.put("description", "Group workout");
values.put("calendar_id", calID);
values.put("eventTimezone", "America/Los_Angeles");
Uri uri = cr.insert(EVENTS_URI, values);

// get the event ID that is the last element in the Uri
long eventID = Long.parseLong(uri.getLastPathSegment());

// add attendee
values = new ContentValues();
values.put("attendeeName", "Trevor");
values.put("attendeeEmail", "[email protected]");
values.put("attendeeRelationship", 1);
values.put("attendeeType", 2);
values.put("attendeeStatus", 3);
values.put("event_id", eventID);
cr.insert(ATTENDEES_URI, values);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文