SyncAdapter not being called depending on order of Account setup calls

百般思念 提交于 2019-12-01 02:29:57
Jarrod Smith

I found that contentResolver.requestSync() will never trigger your SyncAdapter.onPerformSync() unless you call ContentResolver.setIsSyncable(account, getString(R.string.CONTENT_AUTHORITY), 1);.

For a detailed account of the solution I went with using SyncAdapter, see my answer here:

https://stackoverflow.com/a/12015967/988870

I just banged my head against a wall for hours trying to figure out why periodic sync wasn't working. It turns out that the poll frequency needs to be in seconds (literal) not milliseconds, and not seconds in milliseconds. So, for example, if you want it to sync every minute and a half, you would need to call:

            ContentResolver.addPeriodicSync(
                    account,
                    authority,
                    Bundle.EMPTY,
                    90
            );

Also, the bundle passed in cannot be null as it is in the documentation, it will throw a NullPointerException.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!