如何通过修改Android应用程序的日历事件应用程序、日历、事件、Android

2023-09-06 00:41:53 作者:飘渺

我如何可以通过Android应用程序编辑日历的日历事件。

how can i edit the calendar events in calendar via android application..

任何一个知道如何在日历应用程序中打开议程活动......

Any one know how to open the Agenda Activity in the calendar application.....

推荐答案

从日历中读取数据后刚刚尝试了这一点.. 添加单发生的事件到日历

After reading the data from the Calendar just try this out.. Adding a Single-Occurrence Event to a Calendar

要添加一个条目到一个特定的日历,我们需要配置日历项使用ContentValues​​插入如下:

To add an entry to a specific calendar, we need to configure a calendar entry to insert using the ContentValues as follows:

ContentValues event = new ContentValues();

每个事件需要被捆绑到特定的日历,所以你会想设置的第一件事是日历的标识插入此事件为:

Each event needs to be tied to a specific Calendar, so the first thing you're going to want to set is the identifier of the Calendar to insert this event into:

event.put("calendar_id", calId);

然后,我们设定了一些关于事件的基本信息,包括字符串字段,例如事件标题,描述和位置。

We then set some of the basic information about the event, including String fields such as the event title, description and location.

event.put("title", "Event Title");
event.put("description", "Event Desc");
event.put("eventLocation", "Event Location");

有用于配置一个事件的时间和日期的许多不同的选项。

There are a number of different options for configuring the time and date of an event.

我们可以设置事件的开始和结束的信息如下:

We can set the event start and end information as follows:

long startTime = START_TIME_MS;
long endTime = END_TIME_MS;
event.put("dtstart", startTime);
event.put("dtend", endTime);

如果我们要添加生日或节日,我们会设置的入口是一个全天事件:

If we are adding a birthday or holiday, we would set the entry to be an all day event:

event.put("allDay", 1);   // 0 for false, 1 for true

这个信息足以让大多数条目。但是,也有一些其他有用的日历条目的属性。

This information is sufficient for most entries. However, there are a number of other useful calendar entry attributes.

例如,您可以设置事件状态暂定(0),确认(1)或取消(2):

For example, you can set the event status to tentative (0), confirmed (1) or canceled (2):

event.put("eventStatus", 1);

您可以控制​​谁可以通过设置它的可见性默认看到此事件(0),保密(1),私营(2),或公共(3):

You can control who can see this event by setting its visibility to default (0), confidential (1), private (2), or public (3):

event.put("visibility", 0);

您可以控制​​是否事件消耗的时间(可以有时间冲突)在日历上通过其透明度设置为不透明(0)或透明(1)。

You can control whether an event consumes time (can have schedule conflicts) on the calendar by setting its transparency to opaque (0) or transparent (1).

event.put("transparency", 0);

您可以控制​​是否某个事件触发提醒报警如下:

You can control whether an event triggers a reminder alarm as follows:

event.put("hasAlarm", 1); // 0 for false, 1 for true

在日历事件被正确配置,我们就可以使用ContentResolver的插入新的日历进入相应的URI的日历事件:

Once the calendar event is configured correctly, we're ready to use the ContentResolver to insert the new calendar entry into the appropriate Uri for calendar events:

  Uri eventsUri = Uri.parse("content://calendar/events");
  Uri url = getContentResolver().insert(eventsUri, event);

要插入()方法接触的日历内容提供商,并试图插入进入相应的用户日历的电话。如果您导航到日历应用程序并启动它,你应该看到在适当的日历中的日历项。由于日历同步,你还会看到日历项在线,如果您使用的是网络上的谷歌日历。

The call to the insert() method contacts the Calendar content provider and attempts to insert the entry into the appropriate user Calendar. If you navigate to the Calendar application and launch it, you should see your calendar entry in the appropriate Calendar. Since the Calendar syncs, you will also see the Calendar entry online, if you're using the Google Calendar on the web.

添加重复发生的事件到日历

您还可以配置定期日历事件。为了做到这一点,你必须在重复规则的形式添加几个字段事件。该规则规范是基于 RFC2445 。

You can also configure recurring Calendar events. In order to do so, you must add several more fields to the event in the form of a recurrence rule. The rule specification is based upon RFC2445.