这有效:
void strt(){
Calendar beginTime = Calendar.getInstance();
beginTime.set(2018, 2, 14, 7, 30);
Calendar endTime = Calendar.getInstance();
endTime.set(2018, 2, 15, 8, 30);
Intent intent = new Intent(Intent.ACTION_INSERT)
.setData(CalendarContract.Events.CONTENT_URI)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis())
.putExtra(CalendarContract.Events.TITLE, "Yoga")
.putExtra(CalendarContract.Events.DESCRIPTION, "Group class")
.putExtra(CalendarContract.Events.EVENT_LOCATION, "The gym")
.putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY)
.putExtra(Intent.EXTRA_EMAIL, "rowan@example.com,trevor@example.com");
Uri uri = CalendarContract.Events.CONTENT_URI;
//`long eventID = Long.parseLong(uri.getLastPathSegment());`
但是当我添加该行
时long eventID = Long.parseLong(uri.getLastPathSegment());
app停止 附: 我正在尝试获取提醒的eventID
答案 0 :(得分:0)
问题在于" uri"结束"字符串" (就像所说的CommonsWare一样)" uri"没有附加ID。 也许可以通过这种方法附加:
Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);
其中eventID =
long eventID = 188;