Hello I am saving events to device's calendar and wants to set alarm or reminders for the event added. Currently it's adding events but not showing reminders or does not play alarm.
I am expecting an alarm or reminder before 5 minutes from the time of event.
public static long pushAppointmentsToCalender(Activity curActivity, String title, String addInfo,
String place, int status, long startDate, boolean needReminder) {
/***************** Event: note(without alert) *******************/
String eventUriString = "content://com.android.calendar/events";
ContentValues eventValues = new ContentValues();
eventValues.put("title", title);
eventValues.put("description", addInfo);
eventValues.put("eventLocation", place);
long endDate = startDate + 1000 * 60 * 60; // For next 1hr
eventValues.put("dtstart", startDate);
eventValues.put("dtend", endDate);
eventValues.put("eventStatus", status); // This information is
eventValues.put("eventTimezone", "UTC +5:30");
eventValues.put("hasAlarm", 1); // 0 for false, 1 for true
Uri eventUri = curActivity.getApplicationContext().getContentResolver().insert(Uri.parse(eventUriString), eventValues);
long eventID = Long.parseLong(eventUri.getLastPathSegment());
if (needReminder) {
String reminderUriString = "content://com.android.calendar/reminders";
ContentValues reminderValues = new ContentValues();
reminderValues.put("event_id", eventID);
reminderValues.put("minutes", 5); // Default value of the
reminderValues.put("method",1); // Alert Methods: Default(0),
Uri reminderUri = curActivity.getApplicationContext().getContentResolver().insert(Uri.parse(reminderUriString), reminderValues);
}
return eventID;