android - 有没有办法使用 Intents 向新的日历事件添加提醒?

标签 android android-calendar android-2.1-eclair

我需要支持 Android 2.1 及更高版本。我知道 CalendarContract 在 Android 2.1 中不可用,所以我做了以下解决方法。

Intent intent = new Intent(Intent.ACTION_EDIT)
                        .setType("vnd.android.cursor.item/event")
                        .putExtra("beginTime", beginTime.getTimeInMillis())
                        .putExtra("title", title)
                        .putExtra("description", description)
                        .putExtra("eventLocation", location)
                        .putExtra("allDay", allDay)
                        .putExtra(Intent.EXTRA_EMAIL, email );
                if(!allDay) {
                    intent.putExtra("endTime", endTime.getTimeInMillis());
                }

               startActivity(intent);

到目前为止,这工作得很好。我已经在 2.1 到 4.1 上进行了测试。

我也想添加提醒,但我找不到任何关于如何使用 Intents 进行提醒的文档。有人有例子吗?我想避免向我的 list 添加更多权限以写入日历,因此如果您有需要该权限的建议,我将无法使用它。

最佳答案

如果你查看股票android日历源code , 无法使用 intent 添加提醒。

而不是这个日历有一个设置来设置默认提醒。但一些原始设备制造商可能已经实现了这一点。因此,即使您找到它,它也不会在所有手机上运行。

关于android - 有没有办法使用 Intents 向新的日历事件添加提醒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13616470/

相关文章:

java - Listview-点击标题显示描述

android - TextView 上意外的顶部和底部填充?

android - 获取 Android 应用程序中的日历资源列表?

android - 如何在Android中使用自定义日历 View 以及如何设置提醒提醒?

android - 使用 GLSurfaceView 时如何避免在设置 Activity 打开时暂停 android 动态壁纸

安卓; getApplication() 返回 null,不明白为什么

android - GooglePlayServicesUtil.getErrorDialog 为空

Android 从路径加载库

java - 比较时间 : Check if a given time is within a certain amount of time of the another

android - 无法从 Jenkins 签署 Android APK,但可以从命令行运行