Android examples for Android OS:Calendar Event
add Attendees to Calendar Event
import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.provider.CalendarContract; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Calendars; import android.provider.CalendarContract.Events; import android.provider.CalendarContract.Reminders; import android.util.Log; import java.util.ArrayList; import java.util.List; public class Main{ static final String LOG = "CalendarUtil"; public static void addAttendees(Context ctx, List<AttendeeRequest> list) throws Exception { for (AttendeeRequest ar : list) { addAttendee(ctx, ar.getEventID(), ar.getEmail(), ar.getAttendeeName()); }/*from w w w . jav a2 s . c o m*/ } private static void addAttendee(Context ctx, long eventID, String email, String attendeeName) throws Exception { ContentResolver cr = ctx.getContentResolver(); ContentValues values = new ContentValues(); values.put(Attendees.ATTENDEE_NAME, attendeeName); values.put(Attendees.ATTENDEE_EMAIL, email); values.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ATTENDEE); values.put(Attendees.ATTENDEE_TYPE, Attendees.TYPE_REQUIRED); values.put(Attendees.ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_INVITED); values.put(Attendees.EVENT_ID, eventID); Uri u = cr.insert(Attendees.CONTENT_URI, values); Log.i(LOG, "attendee added ... " + attendeeName + "\n" + u.toString()); } }