android 添加日历事件在 android 4.0 中崩溃

标签 android events calendar android-4.0-ice-cream-sandwich

以下是我用来在我的 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/

相关文章:

java - 在 android 中启动 Activity 时获取 NullPointerException

android - 如何将 Firebase 崩溃报告升级为 Firebase Crashlytics?

android - PrimaryDark 未在 android 中设置 StatusBar 颜色

android - 在 phonegap 中模拟 gps 位置

java - 公历错误时间

javascript - 在日期选择器上隐藏日历

javascript - 有没有一种方法可以通过 react 导航创建和分派(dispatch)/触发自定义事件?

java - 如何使子组件只处理它可以处理的事件,而使其他事件保持不变?

c# - 如何在 C# 中实现抽象事件或接口(interface)方法事件?

swift - 计算2个NSDates之间的工作日和周末