Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to edit the calendar events via android application

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.....

like image 607
kannappan Avatar asked Apr 06 '11 09:04

kannappan


2 Answers

After reading the data from the Calendar just try this out..

Adding a Single-Occurrence Event to a Calendar

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.

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

event.put("eventStatus", 1);

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

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

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.

Adding a Recurring Event to a Calendar

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.

like image 148
Hussain Avatar answered Oct 03 '22 01:10

Hussain


this is the exact answer for this question

    Uri uri = Uri.parse("content://calendar/events");
    long eventId = calendeeventid;
    Uri newuri = ContentUris.withAppendedId(uri, eventId);
    Intent intent = new Intent(Intent.ACTION_VIEW,newuri);
    Cursor cursor = getContentResolver().query(newuri, new String[]{"dtstart","dtend",},null, null, null);
    if(cursor.getCount()>0)
    {   cursor.moveToFirst();
    intent.putExtra("beginTime", cursor.getLong(cursor.getColumnIndex("dtstart")));
    intent.putExtra("endTime",  cursor.getLong(cursor.getColumnIndex("dtend")));
    }
like image 35
kannappan Avatar answered Oct 03 '22 02:10

kannappan