Google日历查询最多返回25个条目 [英] Google calendar query returns at most 25 entries

查看:124
本文介绍了Google日历查询最多返回25个条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从今天开始删除所有日历条目.我运行查询,然后在查询结果上调用getEntries(). getEntries()总是返回25个条目(如果日历上少于25个条目,则返回更少).为什么不返回所有条目?我希望大约有80个条目.

I'm trying to delete all calendar entries from today forward. I run a query then call getEntries() on the query result. getEntries() always returns 25 entries (or less if there are fewer than 25 entries on the calendar). Why aren't all the entries returned? I'm expecting about 80 entries.

作为测试,我尝试运行查询,删除返回的25个条目,再次运行查询,再次删除等.此方法可行,但是必须有更好的方法.

As a test, I tried running the query, deleting the 25 entries returned, running the query again, deleting again, etc. This works, but there must be a better way.

下面是仅运行查询一次的Java代码.

Below is the Java code that only runs the query once.

CalendarQuery myQuery = new CalendarQuery(feedUrl);

DateFormat dfGoogle = new SimpleDateFormat("yyyy-MM-dd'T00:00:00'");
Date dt = Calendar.getInstance().getTime();

myQuery.setMinimumStartTime(DateTime.parseDateTime(dfGoogle.format(dt)));
// Make the end time far into the future so we delete everything
myQuery.setMaximumStartTime(DateTime.parseDateTime("2099-12-31T23:59:59"));

// Execute the query and get the response
CalendarEventFeed resultFeed = service.query(myQuery, CalendarEventFeed.class);

// !!! This returns 25 (or less if there are fewer than 25 entries on the calendar) !!!
int test = resultFeed.getEntries().size();

// Delete all the entries returned by the query
for (int j = 0; j < resultFeed.getEntries().size(); j++) {
   CalendarEventEntry entry = resultFeed.getEntries().get(j);

   entry.delete();
}

PS:我看过数据API开发人员指南 Google数据API Javadoc .这些网站还可以,但不是很好.有人知道其他Google API文档吗?

PS: I've looked at the Data API Developer's Guide and the Google Data API Javadoc. These sites are okay, but not great. Does anyone know of additional Google API documentation?

推荐答案

您可以使用myQuery.setMaxResults()增加结果数.不过会有一个最大值,因此您可以通过更改myQuery.setStartIndex()来进行多个查询(分页"结果).

You can increase the number of results with myQuery.setMaxResults(). There will be a maximum maximum though, so you can make multiple queries ('paged' results) by varying myQuery.setStartIndex().

http://code.google.com/apis/gdata/javadoc/com/google/gdata/client/Query.html#setMaxResults(int) http://code. google.com/apis/gdata/javadoc/com/google/gdata/client/Query.html#setStartIndex(int)

这篇关于Google日历查询最多返回25个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆