如何修复日历的意图而不是将其添加为全天事件

How to fix an Intent for calendar not adding it as an all day event

我正在尝试向我的应用程序添加一个按钮,允许某人向他们的日历添加任务。我正在使用 Intent 和 CalendarContract 执行此操作。一切正常,因为它在添加事件状态下启动日历应用程序,并且所有信息都在正确的字段中并正确显示。我唯一遇到的问题是

CalendarContract.EXTRA_EVENT_ALL_DAY to true

不会将其默认为全天活动。

我试过将它分成多个 .putExtra 语句,并尝试过单独的组件,但 none 似乎没有任何区别。

startActivity(Intent(Intent.ACTION_EDIT)
                    .setData(CalendarContract.Events.CONTENT_URI)
                    .setType("vnd.android.cursor.dir/event")
                    .putExtras(
                            bundleOf(
                                    CalendarContract.Events.TITLE to assignment.getItemText(),
                                    CalendarContract.Events.DESCRIPTION to "${assignment.beginDate.takeIf { it != null }?.let { 
                                        "${getString(R.string.start_date)}: ${it.format("MMM dd, h:mm a")}\n\n"} ?: ""}${getString(R.string.due_date)}: ${assignment.dueDate.format("MMM dd, h:mm a")}\n\n${assignment.getDetailText()}",
                                    // If there is just one time, put it in for both so that the generated event in the calendar app has logical and related start/end times
                                    CalendarContract.EXTRA_EVENT_BEGIN_TIME to (assignment.beginDate?.time ?: assignment.dueDate.time),
                                    CalendarContract.EXTRA_EVENT_END_TIME to assignment.dueDate.time,
                                    CalendarContract.EXTRA_EVENT_ALL_DAY to true
                            )
                    )
            )

我预计这将允许我去添加一个已选择全天的事件,但它并没有默认为那个。

我注意到这个问题只发生在 Google 日历

如有帮助将不胜感激。

这似乎是 Android 与 Google 日历集成的当前版本中的错误。希望他们很快会在补丁发布中修复错误。它绝对适用于我测试过的所有其他日历