2012-03-29 14 views
2

フラグメントからcalendarにイベントを挿入しようとしていますが、インテントを処理するアクティビティが見つからないというエラーが発生し続けます。インテント付きカレンダーにイベントを挿入する

ここでエラーです -

android.content.ActivityNotFoundException:いいえ活動はテント{行為は= android.intent.action.INSERT猫= [android.intent.category.APP_CALENDAR] TYP = 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> 

答えて

13

私はIntent intent = new Intent(Intent.ACTION_EDIT)を使用しました。それは問題を解決するように見えた

+1

HTC Sense Android 4.0でも同じ問題がありました。これを行う公式の方法はACTION_INSERTです(参考:http://developer.android.com/guide/topics/providers/calendar-provider.html#intents-9 – Warpzit

+1

AndroidでHTC EVOを使用しています4.0.3、INSERTとEDITの両方でActivityNotFoundExceptionが返されます。 –

0

あなたはすでにそれはあなたが行うようにあなたは、単純に見てデータベースまたsee adding events

にイベントを挿入し、カレンダーアプリを起動する必要はありません見えるの情報を知っていればdocs APP_CALENDARは、でのみ使用されます。ACTION_INSERT

0

一部のデバイスには、Calender Appがインストールされていない可能性があります。 try catchブロック内に囲み、チェックしてください。

Calendar startTymVar = Calendar.getInstance(); 
startTymVar.set(2015, 12, 31, 11, 30); 

Intent calendarIntentVar = new Intent(Intent.ACTION_INSERT) 
      .setData(CalendarContract.Events.CONTENT_URI) 
      .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTymVar.getTimeInMillis()) 
      .putExtra(CalendarContract.Events.TITLE, "New Year") 
      .putExtra(CalendarContract.Events.DESCRIPTION, "Hav ful fun"); 

try 
{ 
    startActivity(calendarIntentVar); 
} 
catch (ActivityNotFoundException ErrVar) 
{ 
    Toast.makeText(this, "Install Calender App", Toast.LENGTH_LONG).show(); 
} 
関連する問題