我已通过我的应用直接创建了日历活动,并添加了提醒功能。他们工作得很好。但是当我点击提醒通知时,它会打开设备日历事件。
现在我想自定义提醒通知以加载我的应用而不加载默认日历。
创建日历活动:
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());
}
提醒:
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);
}
可以自定义吗?请解释一下。