我需要支持 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/