简体   繁体   中英

Android Create Calendar Entry With Reminder Time Not Working

I am trying to create a calendar entry with a reminder

public void createCalendarEntry(){
    Calendar calendar = Calendar.getInstance();
    Intent calIntent = new Intent(Intent.ACTION_INSERT);
    calIntent.setType("vnd.android.cursor.item/event");
    calIntent.putExtra(Events.TITLE, "TITLE");
    calIntent.putExtra(Events.DESCRIPTION, "DECRIPTION");
    calIntent.putExtra(Events.EVENT_LOCATION, "");     
    calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calendar.getTimeInMillis());
    calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, calendar.getTimeInMillis());
    calIntent.putExtra(Events.ALL_DAY, true);
    calIntent.putExtra(Events.STATUS, 1);
    calIntent.putExtra(Events.VISIBLE, 0);
    calIntent.putExtra(Events.HAS_ALARM, true);
    calIntent.putExtra(Reminders.EVENT_ID, 1);
    calIntent.putExtra(Events.ALLOWED_REMINDERS, "METHOD_DEFAULT");
    calIntent.putExtra(Reminders.METHOD, Reminders.METHOD_ALERT);
    calIntent.putExtra(Reminders.MINUTES, 20);
    startActivity(calIntent);
}

This code opens up a new calendar entry with the details filled in but does not fill in the reminder time. The reminder details stay set to default which is 10 minutes - I want to be able to change this value.

Thank you.

You will have to remove this:

calIntent.putExtra(Reminders.EVENT_ID, 1);

As you are creating an event, whose ID will be set dynamically and you are aligning the Reminder parameter values to EVENT_ID = 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM