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

use*_*421 11 android android-2.1-eclair android-calendar

我需要支持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);
Run Code Online (Sandbox Code Playgroud)

到目前为止,这非常有效.我已经在2.1到4.1上进行了测试.

我也想添加提醒,但是我找不到任何关于如何使用Intents的文档.有人有例子吗?我想避免为我的清单添加更多权限以便写入日历,所以如果你有一个需要的建议,我将无法使用它.

nan*_*esh 1

如果您检查库存android日历源代码,则无法使用意图添加提醒。

相反,calendar有一个设置来设置默认提醒。但一些原始设备制造商可能已经实现了这一点。所以即使你找到了它,它也不适用于所有手机。