如何传递被同步到Android中创建活动日历的电子邮件ID? [英] How to pass the email id that to be synchronized into create event calendar in android?

查看:757
本文介绍了如何传递被同步到Android中创建活动日历的电子邮件ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的android意图通过编程方式插入的事件。我们插入标题,描述和时间。但没有发现插入与会者邮件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?

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

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);

我应该用什么来打发键插入电子邮件ID和参与者的ID?任何帮助真的是AP preciated。我的屏幕截图低于

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.

推荐答案

日历提供商是公开的,因为ICS(API级别 - 14)。更多信息这里

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

要添加与会者您需要的事件ID,所以你首先需要添加事件。

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

举例API等级> = 14:

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, "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:

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", "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);

这篇关于如何传递被同步到Android中创建活动日历的电子邮件ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆