无限循环同步syncadapter [英] infinite sync loop syncadapter

查看:133
本文介绍了无限循环同步syncadapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有同样的问题指出:<一href=\"http://stackoverflow.com/questions/7080476/android-syncadapter-stuck-in-infinite-sync-loop\">Android SyncAdapter滞留在无限循环同步

I have the same problem stated here: Android SyncAdapter stuck in infinite sync loop

但试图实现onPerformSync的有NotifyChange(URI URI,ContentObserver观察者,布尔syncToNetwork)后,我意识到,我不知道怎么弄,我需要(这是定义ContentObserver,并在主要活动传递)

But after trying to implement the notifychange (Uri uri, ContentObserver observer, boolean syncToNetwork) in onPerformSync, I realized that I didn't know how to get the ContentObserver that I needed (which is defined and passed in in the main activity)

任何提示?

编辑1:

这样的人第一次同步循环无限期

我发现ContentResolver.cancelSync(帐户,授权);将工作为好,但如果任何人有一个更好的解决方案...请让我知道!

I found that ContentResolver.cancelSync(account, authority); will work as well, but if anyone has a better solution...please let me know!

编辑2:

我跟着从这篇文章的建议<一href=\"http://stackoverflow.com/questions/11090604/android-syncadapter-automatically-initialize-syncing\">Android SyncAdapter自动初始化同步

I followed the advice from this post Android SyncAdapter Automatically Initialize Syncing

使用调试器逐句通过后,我确认,当它传递到有NotifyChange SyncToNetwork是最肯定是假的,但无限的同步持续无cancelSync ......仍然没有永久性的解决方案

after stepping through with the debugger, I confirmed that SyncToNetwork is most definitely false when it is passed into notifyChange, yet the infinite sync continues without the cancelSync...still no permanent solution

推荐答案

我问这个问题前一段时间,当我刚蘸我的脚趾到Android的程序,我想我会分享我发现的人谁是好奇。当我下面的教程来实现自定义的ContentProvider,我看到有NotifyChange(URI URI,ContentObserver观察者)后,已更新()插入()删除()方法。没有真正知道什么,我也叫有NotifyChange 在我的ContentProvider。这导致了像无限循环同步,我只是无法弄清楚的问题。有一个重载的方法:有NotifyChange(URI URI,ContentObserver观察者,布尔syncToNetwork)这是我知道的话,但我永远无法弄清楚如何使用它,因为我的有NotifyChange 是被称为在我的ContentProvider。这实际上是一个容易解决。我所要做的就是调用有NotifyChange(URI,空,假)不在我的ContentProvider,而是通过ContentResolver的调用这些方法后, getContentResolver ().insert()这样等。

I asked this question some time ago when I was just dipping my toes into Android programming, and I figured I'd share what I found for anyone who's curious. When I was following tutorials to implement a custom ContentProvider, I saw that notifyChange (Uri uri, ContentObserver observer) was used after the update(), insert() and delete() methods. Not really knowing anything, I also called notifyChange in my ContentProvider. This led to problems like infinite sync loops that I just could not figure out. There is an overloaded method: notifyChange (Uri uri, ContentObserver observer, boolean syncToNetwork) which I knew about then, but I could never figure out how to use it because my notifyChange was being called in my ContentProvider. This was actually an easy fix. All I had to do was call notifyChange (uri, null, false) not in my ContentProvider, but rather, after calling those methods through the ContentResolver getContentResolver().insert() etc.

我希望这可以帮助别人。

I hope this helps someone.

这篇关于无限循环同步syncadapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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