我有一个带有时间和日期列表的应用程序。当用户单击这些事件之一时,日历意图应启动,因此应调出带有时间、日期和提醒预设的日历。但是,当我加载意图时,开始时间只是当前时间,结束时间是提前一个小时。有人可以告诉我我做错了什么。这是我正在测试的带有日期和时间设置的硬编码日历示例
Calendar startDate = Calendar.getInstance();
startDate.set(Calendar.MONTH, 8);
startDate.set(Calendar.YEAR, 2012);
startDate.set(Calendar.DAY_OF_MONTH, 5);
startDate.set(Calendar.HOUR_OF_DAY, 9);
// Set the calendar
Calendar endDate = Calendar.getInstance();
endDate.set(Calendar.MONTH, 8);
endDate.set(Calendar.YEAR, 2012);
endDate.set(Calendar.DAY_OF_MONTH, 5);
endDate.set(Calendar.HOUR_OF_DAY, 15);
endDate.set(Calendar.MINUTE, 30);
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.putExtra("calendar_id", 1);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", startDate.getTime());
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("allDay", false);
intent.putExtra("endTime", endDate.getTime());
intent.putExtra("title", "A Test Event from android app");
intent.putExtra("description", "Your consulting date and time");
startActivity(intent);