Android 在日历应用程序中向该事件添加事件和多个提醒
我想在日历中添加一个事件,在开始时间前7天和1小时有不同的提醒时间 这就是我正在做的Android 在日历应用程序中向该事件添加事件和多个提醒,android,events,calendar,Android,Events,Calendar,我想在日历中添加一个事件,在开始时间前7天和1小时有不同的提醒时间 这就是我正在做的 long timeInMilliseconds = 0; String date = selectedEvent.eventDate; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date mDate = null; try {
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);
谁能告诉我如何添加提醒
提前感谢。如果要将事件添加到日历中,应使用设置的值调用日历应用程序。由于要添加两个事件,因此必须调用日历应用程序两次,并为这两个应用程序设置不同的值 将事件添加到日历的代码
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, date());
intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);
intent.putExtra(CalendarContract.Events.TITLE, title[i]);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
现在,由于要添加两个提醒,请在
intent.putExtra(CalendarContract.EXTRA\u EVENT\u BEGIN\u TIME,date())处使用日期的不同参数调用此方法两次代码>抱歉,我发布了错误的问题,我想在邮件中添加提醒event@Android试试这个,这不符合我的要求,我希望用户看到预填充日历应用程序,并相应地进行更改