如何以编程方式在Android设备上填充提醒部分';谁的日历应用程序?
我需要用一些预填充的数据打开Android设备的日历应用程序。Iam使用的逻辑似乎填充了以下字段:如何以编程方式在Android设备上填充提醒部分';谁的日历应用程序?,android,calendar,reminders,Android,Calendar,Reminders,我需要用一些预填充的数据打开Android设备的日历应用程序。Iam使用的逻辑似乎填充了以下字段: 事件描述 活动地点 从日期到日期 全天活动/非全天活动 重复/重复信息 我无法填充“提醒”部分,我想填充“提醒”部分。在这方面得到一些帮助将是非常棒的 下面是我用来打开日历应用程序和填充日期的代码 // Intent to open Calendar Event Intent intent = new Intent(Intent.ACTION_INSERT) .se
// Intent to open Calendar Event
Intent intent = new Intent(Intent.ACTION_INSERT)
.setData(Events.CONTENT_URI);
intent.putExtra(Events.DESCRIPTION, desc);
intent.putExtra(Events.EVENT_LOCATION, location);
intent.putExtra(Events.TITLE, summary);
intent.putExtra(Events.EVENT_TIMEZONE, beginTime.getTimeZone().getID());
intent.putExtra(Events.STATUS, statusStr);
intent.putExtra(Events.VISIBLE, transparency);
intent.putExtra(Events.RRULE, "FREQ=YEARLY;INTERVAL=1;BYYEARDAY=1,2;UNTIL=20161210;");
intent.putExtra(Events.EXDATE, androidExDateStr.toString());
// Not sure on how to use CalendarContract.Reminders, Tried the following but does not seem to be working
intent.putExtra(CalendarContract.Reminders.DESCRIPTION, desc);
intent.putExtra(CalendarContract.Reminders.EVENT_LOCATION, location);
intent.putExtra(CalendarContract.Reminders.TITLE, summary);
intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis());
intent.putExtra(CalendarContract.Reminders.DTSTART, beginTime.getTimeInMillis());
intent.putExtra(CalendarContract.Reminders.EVENT_TIMEZONE, beginTime.getTimeZone().getID());
intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis());
intent.putExtra(CalendarContract.Reminders.DTEND, endTime.getTimeInMillis());
intent.putExtra(CalendarContract.Reminders.STATUS, statusStr);
intent.putExtra(CalendarContract.Reminders.RRULE,"FREQ=YEARLY;INTERVAL=1;BYYEARDAY=1,2;UNTIL=20161210;");
intent.putExtra(CalendarContract.Reminders.EXDATE, androidExDateStr.toString());
//intent.putExtra(CalendarContract.Reminders.METHOD, Reminders.METHOD_EMAIL);
//intent.putExtra(CalendarContract.Reminders.MINUTES, reminderVal) ;
//intent.putExtra(CalendarContract.Events.HAS_ALARM, 1);
//}
try {
context.startActivity(intent);
} catch(Exception e) {
e.printStackTrace();
Log.v(LOG_TAG, "Cannot schedule Calendar event as specified ");
return false;
}
您是否检查了来自的示例
本例使用另一种方法,即应用程序直接将数据写入日历。OP使用了一种不同的方法,他的应用程序使用预填充的数据打开日历应用程序,这些数据可用于创建日历事件。
long eventID = 221;
...
ContentResolver cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(Reminders.MINUTES, 15);
values.put(Reminders.EVENT_ID, eventID);
values.put(Reminders.METHOD, Reminders.METHOD_ALERT);
Uri uri = cr.insert(Reminders.CONTENT_URI, values);