I want to add an event to calender with different reminder time 7 days before and 1 hour before the start time
Here is what i am doing
long timeInMilliseconds = 0;
String date = selectedEvent.eventDate;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date mDate = null;
try {
mDate = sdf.parse(date);
timeInMilliseconds = mDate.getTime();
System.out.println("Date in milli :: " + timeInMilliseconds);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(mDate);
cal.set(Calendar.HOUR_OF_DAY, 8);
cal.set(Calendar.MINUTE, 00);
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", false);
// intent.putExtra("rrule", "FREQ=YEARLY");
cal.add(Calendar.HOUR_OF_DAY, 8);
intent.putExtra("endTime", cal.getTimeInMillis());
intent.putExtra("title", selectedEvent.name);
String body = "";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Log.d("", "Timzone--" + format.getTimeZone());
Date convertedDate = new Date();
try {
convertedDate = format.parse(selectedEvent.eventDate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
outputFormat.setTimeZone(TimeZone.getDefault());
body += outputFormat.format(convertedDate) + "\n";
body += selectedEvent.name + "\n";
body += selectedEvent.format + "\n";
body += selectedEvent.remark1 + "\n";
body += selectedEvent.remark2 + "\n";
body.replaceAll("null", "");
intent.putExtra("description", body);
intent.putExtra(CalendarContract.Events.EVENT_LOCATION, plat);
intent.putExtra(CalendarContract.Events.HAS_ALARM, 1);
startActivity(intent);
Can anyone tell me how to add reminder
Thank you in advance.
If you want to add an event to a calendar, you should call the Calendar app with the values set. Since you want to add two events, you have to call the Calendar app twice and set different values to both.
Code to add event to Calender
Now since you want to add two reminders, call this method twice with different parameters for date at
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, date());