alarm/reminder 的事件被删除后会自动删除吗?
Does alarm/reminder get automatically deleted when its event is deleted?
我创建了一个 HAS_ALARM
设置为 1
的日历事件,如下所示:
contentResolver.insert(
Uri.parse("content://com.android.calendar/calendars"),
contentValuesOf(
CalendarContract.Events.CALENDAR_ID to calendarId,
CalendarContract.Events.TITLE to event.title,
CalendarContract.Events.EVENT_LOCATION to event.location,
CalendarContract.Events.DESCRIPTION to event.description,
CalendarContract.Events.DTSTART to event.startTimeInMillis,
CalendarContract.Events.DTEND to event.endTimeInMillis,
CalendarContract.Events.EVENT_TIMEZONE to event.zoneName,
CalendarContract.Events.HAS_ALARM to 1
)
)
然后我为上面创建的事件创建一个提醒如下:
contentResolver.insert(
Uri.parse("content://com.android.calendar/reminders"),
contentValuesOf(
CalendarContract.Reminders.EVENT_ID to it,
CalendarContract.Reminders.METHOD to CalendarContract.Reminders.METHOD_ALERT,
CalendarContract.Reminders.MINUTES to reminderTimeInMinutes
)
)
我在需要时删除事件,如下所示:
contentResolver.delete(
Uri.parse("content://com.android.calendar/events"),
String.format(
"%s = ? and %s = ? and %s = ?",
CalendarContract.Events.TITLE,
CalendarContract.Events.DTSTART,
CalendarContract.Events.DTEND
),
arrayOf(event.title, event.startTimeInMillis.toString(), event.endTimeInMillis.toString())
)
但是,我无法删除它的提醒,因为我没有保留事件 ID。
当我删除它的事件时,提醒会自动删除吗?如果没有,如何删除提醒,最好不存储任何id?
似乎在删除活动时自动删除了活动的提醒。
我创建了一个 HAS_ALARM
设置为 1
的日历事件,如下所示:
contentResolver.insert(
Uri.parse("content://com.android.calendar/calendars"),
contentValuesOf(
CalendarContract.Events.CALENDAR_ID to calendarId,
CalendarContract.Events.TITLE to event.title,
CalendarContract.Events.EVENT_LOCATION to event.location,
CalendarContract.Events.DESCRIPTION to event.description,
CalendarContract.Events.DTSTART to event.startTimeInMillis,
CalendarContract.Events.DTEND to event.endTimeInMillis,
CalendarContract.Events.EVENT_TIMEZONE to event.zoneName,
CalendarContract.Events.HAS_ALARM to 1
)
)
然后我为上面创建的事件创建一个提醒如下:
contentResolver.insert(
Uri.parse("content://com.android.calendar/reminders"),
contentValuesOf(
CalendarContract.Reminders.EVENT_ID to it,
CalendarContract.Reminders.METHOD to CalendarContract.Reminders.METHOD_ALERT,
CalendarContract.Reminders.MINUTES to reminderTimeInMinutes
)
)
我在需要时删除事件,如下所示:
contentResolver.delete(
Uri.parse("content://com.android.calendar/events"),
String.format(
"%s = ? and %s = ? and %s = ?",
CalendarContract.Events.TITLE,
CalendarContract.Events.DTSTART,
CalendarContract.Events.DTEND
),
arrayOf(event.title, event.startTimeInMillis.toString(), event.endTimeInMillis.toString())
)
但是,我无法删除它的提醒,因为我没有保留事件 ID。
当我删除它的事件时,提醒会自动删除吗?如果没有,如何删除提醒,最好不存储任何id?
似乎在删除活动时自动删除了活动的提醒。