11
我需要支持Android 2.1及更高版本。我知道CalendarContract在Android 2.1中不可用,所以我已經完成了以下解決方法。有沒有辦法使用Intents將提醒添加到新的日曆事件?
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的文檔。有沒有人有一個例子?我想避免爲我的清單添加更多權限以寫入日曆,所以如果您有建議需要,我將無法使用它。
如果您查看股票的android源代碼,則無法添加通過intent的reeminder。但一些原始設備製造商可能已經實現了這一點所以,即使你找到它,它也不會在所有手機上都能正常工作。 – nandeesh
@nandeesh我認爲這將最好地作爲答案,因爲它似乎是真的,情況就是如此。如果其他人會證實,我想將其標記爲答案。 – user5243421