【发布时间】:2011-07-19 03:12:10
【问题描述】:
有很多关于如何在 android 中创建新日历事件的示例,但没有关于如何打开和显示事件的示例。这是我目前的代码
public static void startCalendarMimeType(Context context, CalendarItem item){
//all version of android
Intent i = new Intent();
// mimeType will popup the chooser any for any implementing application (e.g. the built in calendar or applications such as "Business calendar"
i.setType("vnd.android.cursor.item/event");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// the time the event should start in millis. This example uses now as the start time and ends in 1 hour
//i.putExtra("beginTime", item.getBegin());
//i.putExtra("endTime", item.getEnd());
i.putExtra("_id", item.getId());
// the action
//i.setAction(Intent.ACTION_PICK);
context.startActivity(i);
}
日历项包含已使用内容解析器从日历中检索到的信息。当用户单击我的项目时,我希望它打开显示该项目的 Android 日历。
此时您可以选择要打开的应用程序,如果您选择“显示事件”,它会打开日历应用程序,但会出现空指针异常,我只是不知道我在这里做错了什么。我是第一个尝试这样做的人吗?
非常感谢任何帮助
【问题讨论】: