gpt4 book ai didi

android - 如何修复日历的 Intent 而不是将其添加为全天事件

转载 作者:行者123 更新时间:2023-11-29 22:52:39 24 4
gpt4 key购买 nike

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

CalendarContract.EXTRA_EVENT_ALL_DAY to true

并未将其默认为全天 Activity 。

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

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 日历集成中的一个错误。希望他们很快会在补丁发布中修复错误。它绝对适用于我测试过的所有其他日历

关于android - 如何修复日历的 Intent 而不是将其添加为全天事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57732524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com