我試圖從一個片段插入事件到calendar
,但我一直收到一個錯誤消息,發現沒有任何活動處理意圖。錯誤將事件插入帶有意圖的日曆
這裏的錯誤 -
android.content.ActivityNotFoundException:無活動處理意向{行動= android.intent.action.INSERT貓= [android.intent.category.APP_CALENDAR]典型值= VND .android.cursor.item /事件(有演員)}
這裏是我的代碼:
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);
意圖過濾
<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>
與HTC Sense Android 4.0有同樣的問題。它令人討厭,因爲這樣做的官方方式是ACTION_INSERT(參考:http://developer.android.com/guide/topics/providers/calendar-provider.html#intents-9 – Warpzit 2012-08-10 08:16:13
我使用HTC EVO與Android 4.0.3和INSERT和EDIT都給了我ActivityNotFoundException。 – 2013-08-12 08:49:09