This is my code to view an event selected from a ListActivity (events is the ArrayList containing all those events):
Uri viewUri = Uri.parse("content://com.android.calendar/events/" + events.get(position).id);
Intent l_intent = new Intent(Intent.ACTION_VIEW);
l_intent.putExtra("beginTime", Long.parseLong(events.get(position).startTime));
l_intent.putExtra("endTime", Long.parseLong(events.get(position).endTime));
startActivity(l_intent);
This code works perfectly for all events except recurring events. For any event that is recurring, endTime returns as null, causing the program to crash. Anyone know how to get around this? Are there other extras I should be passing?
beginTime and endTime can be 0/null because you got them from a wrong database, certainly from events database.
You should use the instances database instead (ex: “content://com.android.calendar/instances/when/” on SDK 8).
In the instances DB, you’ll get all “real” events : There, each recurring event has as many instances as needed, with correct begin and end timestamps; and the other events are visible too. You only have to read these fields – event_id, begin, end – and use them to open your Intent.