如何将带有提醒的事件添加到日历?

时间:2019-10-28 01:15:19

标签: java android events reminders calendarcontract

添加事件时,它可以完美地工作,我可以添加事件的所有数据,但要提醒一下它不起作用,我应该更改什么?

这是我的代码

            Intent intent = new Intent(Intent.ACTION_INSERT);
            intent.setType("vnd.android.cursor.item/event");

            String id="123";

            GregorianCalendar fechaSeleccionada = new GregorianCalendar(year, month, dayOfMonth);

            intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
                    fechaSeleccionada.getTimeInMillis());

            intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
                    fechaSeleccionada.getTimeInMillis());
            intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

            intent.putExtra(CalendarContract.EXTRA_EVENT_ID, id);

            //This is Information about Calender Event.
            intent.putExtra(CalendarContract.Events.TITLE, "Siddharth Birthday");
            intent.putExtra(CalendarContract.Events.DESCRIPTION, "This is a description");
            intent.putExtra(CalendarContract.Events.EVENT_LOCATION, "My Guest House");
            intent.putExtra(CalendarContract.Events.RRULE, "FREQ=YEARLY");

            //This is Information about Reminders.
            intent.putExtra(CalendarContract.Reminders.EVENT_ID, id);
            intent.putExtra(CalendarContract.Reminders.MINUTES, 60);
            intent.putExtra(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT);

            startActivity(intent);

0 个答案:

没有答案