来自Stack Overflow问题如何在Android中添加日历事件?我开始知道如何添加日历事件,但是具体的启动时间(小时和分钟)和结束时间(小时和分钟).我们如何添加?
做这样的事情。这里的 startDate 是你想要开始的时间。
long startTime,endTime;
String startDate = "2011-09-01";
try {
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(startDate);
startTime=date.getTime();
}
catch(Exception e){ }
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime",startTime);
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", endTime);
intent.putExtra("title", "A Test Event from android app");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6053 次 |
| 最近记录: |