Marshmellowデバイスで以下のコードを使用してプログラムでカレンダーにイベントを追加していますが、動作していません。何か案が?カレンダーアプリでこのイベントが表示されません。イベントを予定表にプログラムで追加する
long startMillis = 0;
long endMillis = 0;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null, endDate = null;
try{
startDate = simpleDateFormat.parse("2017-05-01 01:30:00");
startMillis = startDate.getTime();
endDate = simpleDateFormat.parse("2017-05-01 03:30:00");
endMillis = endDate.getTime();
}catch (ParseException e){
e.printStackTrace();
}
ContentResolver cr = this.getContentResolver();
ContentValues values = new ContentValues();
TimeZone timeZone = TimeZone.getDefault();
values.put(CalendarContract.Events.DTSTART, startMillis);
values.put(CalendarContract.Events.DTEND, endMillis);
values.put(CalendarContract.Events.EVENT_TIMEZONE, timeZone.getID());
values.put(CalendarContract.Events.TITLE, "Hello Title");
values.put(CalendarContract.Events.DESCRIPTION, "Add events to Calendar");
values.put(CalendarContract.Events.CALENDAR_ID, 879);
Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
PS:唯一のGmailアカウントがカレンダーアプリと同期された場合、それが動作します。
エラーが表示されますか?これを読む[回答](http://stackoverflow.com/questions/34959858/add-event-and-reminder-not-working-in-6-0-marshmallow) – Piyush
@Piyushエロスはありません。 – Aniruddha
私が共有しているリンクを読む – Piyush