繁体   English   中英

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

[英]How to pass the email id that to be synchronized into create event calendar in android?

在android中,我们通过intent以编程方式插入事件。 我们插入标题,描述和时间。 但是没有找到将参加者邮件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? 任何帮助真的很感激。 我的屏幕截图低于。

自ICS(API Level-14)以来,Calendar Provider是公开的。 更多信息在这里

要添加与会者,您需要事件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, "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);
cr.insert(Attendees.CONTENT_URI, values);

API级别<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", "trevor@example.com");
values.put("attendeeRelationship", 1);
values.put("attendeeType", 2);
values.put("attendeeStatus", 3);
values.put("event_id", eventID);
cr.insert(ATTENDEES_URI, values);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM