我有开会的申请。可以通过Outlook日历进行预订。一切都很好,但是如果您每周或每月进行一次活动,那么在我的应用程序中它将无法正常工作。仅在第一天,然后看不到这些重复事件。我的代码有什么问题?如何让我的应用看到每周重复的活动?我发现的例子对我没有帮助。
public static synchronized ArrayList<Meeting> getMeetings(RMApplication application, Mailbox mailbox) throws ServiceException {
if (isDemo(application)) throw new ServiceException("demo");
Service service = getService(application.getApplicationContext());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdfEndDay = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
Date startTime = new Date();
Date endTime = new Date();
try {
endTime = sdf.parse(sdfEndDay.format(new Date()));
} catch (ParseException e) {
e.printStackTrace();
}
IsGreaterThanOrEqualTo restriction1 = new IsGreaterThanOrEqualTo(AppointmentPropertyPath.END_TIME, startTime);
IsLessThanOrEqualTo restriction2 = new IsLessThanOrEqualTo(AppointmentPropertyPath.END_TIME, endTime);
And restriction3 = new And(restriction1, restriction2);
StandardFolderId calendarFolder = new StandardFolderId(StandardFolder.CALENDAR, mailbox);
List<PropertyPath> props = AppointmentPropertyPath.getAllPropertyPaths();
FindItemResponse response = service.findItem(calendarFolder, props, restriction3);
ArrayList<Meeting> appointments = new ArrayList<Meeting>();
Date currentDate = new Date();
int counter = 0;
for (int i = 0; i < response.getItems().size(); i++) {
if (response.getItems().get(i) instanceof Appointment) {
if (DateUtils.compare(currentDate, ((Appointment) response.getItems().get(i)).getEndTime()) <= 0) {
Appointment a;
try {
if (counter < 1) {
if (((Appointment) response.getItems().get(i)).getSubject().equals(application.getResources().getString(R.string.default_meeting_subject))) {
counter++;
throw new ServiceException("Counter limit");
}
a = getService(application.getApplicationContext()).getAppointment(((Appointment) response.getItems().get(i)).getItemId());
counter++;
} else {
throw new ServiceException("Counter limit");
}
} catch (ServiceException ex) {
ex.printStackTrace();
a = (Appointment) response.getItems().get(i);
}
appointments.add(new Meeting(a));
}
}
}
return appointments;
}