I'm trying to add events to calendar with the following code :
public Intent calPopulation()
{
Intent calIntent = new Intent(Intent.ACTION_INSERT);
calIntent.setType("vnd.android.cursor.item/event");
calIntent.putExtra(CalendarContract.Events.TITLE, this._title);
GregorianCalendar calDate = new GregorianCalendar(this._year,this._month, this._day, this._hour, this._minute);
calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calDate.getTimeInMillis());
calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, calDate.getTimeInMillis()+60*60*1000);
calIntent.putExtra(CalendarContract.Events.HAS_ALARM, true);
calIntent.putExtra(CalendarContract.Reminders.EVENT_ID, CalendarContract.Events._ID);
calIntent.putExtra(CalendarContract.Events.ALLOWED_REMINDERS, "METHOD_DEFAULT");
calIntent.putExtra(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
calIntent.putExtra(CalendarContract.Reminders.MINUTES,5);
return calIntent;
}
And then launch the action with : startActivity(mTask.calPopulation());
I don't have any issue, the calendar app event launched with the correct information I entered into my app, except that it does not fill in the event the reminder I would like to add.
Do you have any clues? I tried to search within many threads using this method (I mean the intent.putExtra) but never find anything interesting.
Other point, is there a way to directly save the event + reminder into the calendar without opening calendar App and requesting for user action?
Thanks in advance. Alex.
Intent
and not directly adding it? - Zapnologica