使用 AccountManager addAccountExplicitly 第一次同步需要很长时间
我使用 AccountManager addAccountExplicitly() 将帐户添加到 AccountManager。 然后我打电话
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
这样做之后,当查看设备的“帐户和同步”屏幕时,我看到了我的帐户,但是当我单击时,我看到“同步联系人”复选框没有出现。 它可能需要几分钟的时间才能出现...
我发现,如果我听到正在添加的帐户,并在延迟(2秒)调用后:
ContentResolver.requestSync(account, ContactsContract.AUTHORITY, new Bundle());
它正在同步。
1.为什么账户同步需要一段时间? 2.这是使帐户立即同步的正确方法吗? (这总是有效吗?)
I use AccountManager addAccountExplicitly() to add an account to AccountManager.
I then call
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
After doing that, when looking in the device's "Accounts & sync" screen, i see my account BUT when I click on in, I see that the "Sync contacts" check box does not appear.
It may take a few minutes for it to appear...
I found out that if I listen to the account being added, and after a delay (2 secs) call:
ContentResolver.requestSync(account, ContactsContract.AUTHORITY, new Bundle());
It is being synced.
1.why does it take time for the account to sync?
2.is this the correct way to make the account sync immediately? (will this always work?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题,这个答案中的编辑部分对我有帮助。 首次同步无限循环
在第一次同步时,调用
cancelSync
并再次尝试同步。I had a similar issue and the edited part in this answer helped me. First time sync loops indefinitely
On the first sync, call
cancelSync
and try sync again.