カレンダーに新しいイベントを追加しようとしています (最小 SDK バージョンは 2.2 です)。
それは私がこれまで持っているコードです:
ContentValues event = new ContentValues();
event.put("calendar_id", 2);
event.put("title", "mytitle");
event.put("description", "desc");
event.put("eventLocation", "loc");
event.put("eventTimezone", Calendar.getInstance().getTimeZone().getDisplayName());
long startTime = System.currentTimeMillis() + 1000 * 60 * 60;
Long duration = 1000L * 60 * 30;
event.put("dtstart", startTime);
event.put("duration", duration);
Uri eventsUri = Uri.parse("content://com.android.calendar/events");
Uri insertedUri = getContentResolver().insert(eventsUri, event);
しかし、insertedUri
は常に null です。
また、logcat で次の行を確認できます。
Failed to find provider info for calendar
誰でもそれで私を助けることができますか?
ありがとう。