使用Android 5的Nexus 5:
我正在设置日历活动,主题,时间,闹钟,信息以及位置(城市,街道和街道号码) 当我设置活动并在日历应用程序中打开它时,我可以看到我设置的位置,我可以使用谷歌地图打开它。
几分钟后(同步?)当我打开事件时,除了位置外,所有数据都在那里。
在其他设备(较低的api级别)上同步事件并保存位置......
这是我将事件推送到日历的代码:
public static long pushAppointmentsToCalender(Activity curActivity, String title, String addInfo, String place, int status, long startDate, int length, int reminderMinutesBefore) {
String eventUriString = getCalendarEventsUri();
ContentValues eventValues = new ContentValues();
eventValues.put("calendar_id", 1); // id We need to choose from our mobile for primary==>its 1
eventValues.put("title", title);
eventValues.put("description", addInfo);
eventValues.put("eventLocation", place);
long endDate = startDate + length;
eventValues.put("dtstart", startDate);
eventValues.put("dtend", endDate);
eventValues.put("eventStatus", status); // This information is
eventValues.put("hasAlarm", 1); // 0 for false, 1 for true
eventValues.put("eventTimezone", TimeZone.getDefault().getID());
Uri eventUri = curActivity.getApplicationContext().getContentResolver().insert(Uri.parse(eventUriString), eventValues);
long eventID = Long.parseLong(eventUri.getLastPathSegment());
if (reminderMinutesBefore != -1) {//Event: Reminder(with alert) Adding reminder to event
String reminderUriString = "content://com.android.calendar/reminders";
ContentValues reminderValues = new ContentValues();
reminderValues.put("event_id", eventID);
reminderValues.put("minutes", reminderMinutesBefore); // Default value of the
reminderValues.put("method", 1); // Alert Methods: Default(0), Alert(1), Email(2), SMS(3)
Uri reminderUri = curActivity.getApplicationContext().getContentResolver().insert(Uri.parse(reminderUriString), reminderValues);
}
Logger.log("pushAppointmentsToCalender==>Event Created with eventId:" + eventID);
return eventID;
}
答案 0 :(得分:2)