以下是我用来在我的 android 应用程序中添加事件的代码
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(Events.TITLE, summary);
intent.putExtra(Events.DESCRIPTION, summary);
intent.putExtra(Events.EVENT_LOCATION, "");
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginCal.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endCal.getTimeInMillis());
intent.putExtra(Events.ALL_DAY, allDayFlag);
intent.putExtra(Events.STATUS, 1);
intent.putExtra(Events.VISIBLE, 0);
intent.putExtra(Events.HAS_ALARM, 1);
startActivity(intent);
此代码在 android 4.0 模拟器中运行良好,但当我检查 Samsung Galaxy S II of andriod 4.0 时,它崩溃了,错误日志似乎如下所示
Error ( 4489): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT typ=vnd.android.cursor.item/event (has extras) }
如何纠正这个错误
最佳答案
尝试使用 Intent.ACTION_EDIT
代替。
关于android 添加日历事件在 android 4.0 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10662944/