Find Event Organizer - Android Calendar Events

226 Views Asked by At

I have tried to find the a Organizer of an Event in Android. The Calendar query is given blow.

String[] projection = new String[] { "calendar_id", "title", "description",
                "dtstart", "dtend","organizer", "eventLocation","hasAttendeeData","_id"};

String selection = "(\" + CalendarContract.Events.CALENDAR_ID + \" = ?) OR ((dtstart >= "+cal_Start.getTimeInMillis()+") AND (dtend <= "+cal_End.getTimeInMillis()+"))";
String[] selectionArgs = new String[] { String.valueOf(1)};

Cursor cursor = context.getContentResolver()
                .query(
                        Uri.parse("content://com.android.calendar/events"),projection
                        , selection,
                        selectionArgs, null);

cursor.moveToFirst();

I can get the events title, start date, end date etc. But, The organizer simply returns the string "organizer" itself. As per documentation need to get the email Id of the organizer. How can I solve this issue

1

There are 1 best solutions below

1
Bob Snyder On

Some calendar apps do not provide the capability to enter event attendees or invitees. I have two such calendar apps on older Samsung and Motorola phones. When an event is created by a calendar app without attendee capabilities, the apps store a fixed dummy value in the organizer field such as "local@phone" or "My calendar".

If you create an event using a calendar app that has the capability to enter attendees, I expect you will see a valid organizer email. Code that is logically equivalent to what you posted works for me.