使用Intent将事件插入日历时出错

MrE*_*r13 2 android calendar android-intent

我正在尝试calendar从一个片段插入事件,但我一直收到错误,没有发现任何活动来处理Intent.

这是错误 -

android.content.ActivityNotFoundException:找不到处理Intent的Activity {act = android.intent.action.INSERT cat = [android.intent.category.APP_CALENDAR] typ = vnd.android.cursor.item/event(has extras)}

这是我的代码:

Intent intent = new Intent(Intent.ACTION_INSERT);
intent.addCategory(Intent.CATEGORY_APP_CALENDAR);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(Events.TITLE, "Phototherapy Treatment");
intent.putExtra(Events.EVENT_LOCATION, "");
intent.putExtra(Events.DESCRIPTION, "Phototherapy Treatment");

// Setting dates
Calendar calDate = Calendar.getInstance();
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,calDate.getTimeInMillis());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis()+60*60*1000);

// Make it a full day event
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);

// Make it a recurring Event                    
intent.putExtra(Events.RRULE, "FREQ=WEEKLY;COUNT="+Integer.valueOf(No.getText().toString())+";"
+"WKST=SU;BYDAY="+days);

// Making it private and shown as busy
 intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
 intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);

startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

意图过滤器

<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<action android:name="android.intent.action.INSERT" /> 
<category android:name="android.intent.category.APP_CALENDAR" /> 
<data android:mimeType="vnd.android.cursor.item/event" /> 
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

MrE*_*r13 13

我使用了Intent intent = new Intent(Intent.ACTION_EDIT); 它似乎解决了这个问题