You can open the calendar window as follows:
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setData(CalendarContract.Events.CONTENT_URI);
startActivity(intent);
If you need to add dates use as follows:
//Cria uma intent para abertura de uma nova activity.
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType("vnd.android.cursor.item/event");
//Configurações do evento.
intent.putExtra(Events.TITLE, "Teste de Titulo");
intent.putExtra(Events.EVENT_LOCATION, "Local do evento");
intent.putExtra(Events.DESCRIPTION, "Teste de descrição");
//Configuração de data do evento
GregorianCalendar calDate = new GregorianCalendar(2014, 28, 08);
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis());
//Marca o evento como dia inteiro.
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
//Define se será repetido
intent.putExtra(Events.RRULE, "FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH");
//Marca como privado e como ocupado.
intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
If you want to use inside your application, you will have to do different.
There is this third party library that I found very interesting and is beautiful, it can help you.
https://github.com/roomorama/Caldroid
Hug.
Bruno, there is a Google Calendar API, but it needs the internet and the access is done by REST to the google endpoint ( https://developers.google.com/google-apps/calendar/get_started). The API has a Java client. Another alternative is to use the Calendar Provider to access and modify your device’s local calendars without the need for internet. However it is only available for the SDK 14+, take a look at: http://developer.android.com/guide/topics/providers/calendar-provider.html. I haven’t used it yet, but soon I will need it and I think I will go through the Calendar Provider.
– Wakim