Customize calendar event reminder notification

494 views Asked by At

I have directly created a calendar event through my app and added reminder also. They are working perfectly. But when I click reminder notification, it's opening device calendar event.

Now I want to customize reminder notification to load my app without loading default calendar.

Creating calendar event:

public Long addEventToCalendar(long dateStart, long dateEnd, String eventTitle, boolean isAllDay, boolean isRecurring) {
    ContentResolver cr = context.getContentResolver();
    ContentValues eventValues = new ContentValues();
    eventValues.put(CalendarContract.Events.DTSTART, dateStart);
    eventValues.put(CalendarContract.Events.DTEND, dateEnd);
    eventValues.put(CalendarContract.Events.TITLE, eventTitle);
    eventValues.put(CalendarContract.Events.DESCRIPTION, context.getResources().getString(R.string.app_name));
    eventValues.put(CalendarContract.Events.CALENDAR_ID, 1);
    eventValues.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());
    eventValues.put(CalendarContract.Events.HAS_ALARM, 1);
    Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, eventValues);

    // get the event ID that is the last element in the Uri
    return Long.parseLong(uri.getLastPathSegment());
}

Reminder:

 public void setReminder(long eventID, int notifyTime) {
    ContentResolver cr = context.getContentResolver();
    ContentValues reminderValues = new ContentValues();
    reminderValues.put(CalendarContract.Reminders.MINUTES, notifyTime);
    reminderValues.put(CalendarContract.Reminders.EVENT_ID, eventID);
    reminderValues.put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);
    Uri uri = cr.insert(CalendarContract.Reminders.CONTENT_URI, reminderValues);
}

Is it possible to customize it? Please explain how.

0

There are 0 answers