谷歌-API的Java的客户端在Android上无限循环谷歌日历 [英] google-api-java-client for Google Calendar on Android Infinite loop

查看:103
本文介绍了谷歌-API的Java的客户端在Android上无限循环谷歌日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在挣扎与集成发现了一些谷歌日历功能<一提供的谷歌样本Android应用href="http://$c$c.google.com/p/google-api-java-client/source/browse?repo=samples#hg/calendar-v2-atom-android-sample"相对=nofollow>此处在谷歌code。

I have been struggling with the sample android application provided by Google for integrating some Google calendar functionality found here at Google code.

我已经修改了原来的code只是一点点。具体而言,在<一href="http://$c$c.google.com/p/google-api-java-client/source/browse/calendar-v2-atom-android-sample/src/com/google/api/client/sample/calendar/android/CalendarAndroidSample.java?repo=samples"相对=nofollow>在线路326 CalendarAndroidSample.java 类我修改

I've modified the original code just a tad. Specifically, in the CalendarAndroidSample.java class at line 326 I've modified:

CalendarUrl url = CalendarUrl.forAllCalendarsFeed();

目前计算:

CalendarUrl url = CalendarUrl.forEventFeed(settings.getString("accountName", "NULL"), "private", "full");

本填充所有事件的列表视图中我的日历就好了。

This fills the listview with all of the events in my calendar just fine.

每当我添加事件,以我的谷歌日历出现的无限循环。一旦一个新的事件被添加,示例应用程序冻结了起来,看着那DDMS我可以看到logcat的吐出这多次没有结束:

The infinite loop occurs whenever I add an event to my google calendar. Once a new event is added, the sample app freezes up, and looking at the DDMS I can see the logcat spitting out this repeatedly without an end:

06-19 11:19:28.556: DEBUG/dalvikvm(7493): GC_FOR_MALLOC freed 11761 objects / 519744 bytes in 39ms

这是我发现从循环停止的应用程序的唯一方法是删除日历事件。一旦日历事件被删除,应用程序起死回生,并列出我的事件,但是,列表视图现在包含了我所有的事件,重复了一遍又一遍。这就像进永不停歇。

The only way that I've found to stop the app from looping is to delete the calendar event. Once the calendar event is deleted, the app comes back to life and lists my events, BUT, the listview now contains all of my events, repeated over and over again. It's like the feed never stops.

我最好的猜测是,在线路333,其中code读取:

My best guess is that at line 333, where the code reads:

String nextLink = feed.getNextLink();
    if (nextLink == null) {
      break;

NEXTLINK不会变空,从而创造循环。但是,为什么会出现这种情况只有当我添加一个日历事件?

nextLink never becomes null, thus creating the loop. But why does this happen ONLY when I add a calendar event?

编辑:

我删除了一些日历事件,并开始工作。它好像如果日历已超过25事件,它开始循环?这样做有什么意义呢?!

I deleted some calendar events and it started working. It seems as though if the calendar has more than 25 events, it starts to loop? What is the meaning of this?!

推荐答案

我会实现我的纯粹的愚蠢后删除这个帖子,但我会留给别人谁狂跌不止像我一样。

I was going to remove this post after realizing my sheer stupidity, but I'm going to leave it up for others who fall hard like me.

在无限循环中被创建,因为NEXTLINK从来没有成为空时,我曾在我的日历超过25个事件。我猜,如果没有为maxResults设定值,则默认值为25。因此,当我的超过在我的日历25事件,一个空NEXTLINK不可能存在,因为凌动返回有整整25事件。

The infinite loop was being created because nextLink never became null when I had more than 25 events in my calendar. I'm guessing that without setting a value for maxResults, the default is 25. Hence, when I had more than 25 events in my calendar, a "null" nextLink could never exist because the Atom returned has exactly 25 events.

如果我设置maxResults为50,在我的日历只存在49事件,50 NEXTLINK是空从而引发从循环休息。

If I set maxResults to 50 and only 49 events exist in my calendar, the 50th nextLink would be null thus triggering the break from the loop.

我刚才设置maxResults到一个巨大的数字像100万。我想如果一个人每天都在他们的日历10事件,并活到80岁了,那只能等同于各地的291000事件。我想1,000,000一个安全的数字。

I have just set maxResults to a huge number like 1,000,000. I figure if a person has 10 events in their calendar every day and lives to be 80 years old, that would only equate to around 291,000 events. I figure 1,000,000 is a safe number.

这篇关于谷歌-API的Java的客户端在Android上无限循环谷歌日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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