定期同步每次运行

时间:2019-03-19 18:50:05

标签: android synchronization

我正在尝试在我的android应用中建立定期同步,以使其每1小时定期运行一次。我正在从android开发者网站关注以下示例:

ContentResolver.addPeriodicSync(createDummyAccount(this, "account name"),
                MyContentProvider.AUTHORITY,
                Bundle.EMPTY, getResources().getInteger(R.integer.periodic_sync_interval));

问题在于,每次启动活动(即使在一分钟内)都会触发同步。

可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

请检查间隔文档: https://developer.android.com/reference/android/content/ContentResolver.html#addPeriodicSync(android.accounts.Account,%20java.lang.String,%20android.os.Bundle,%20long)

pollFrequency   long: how frequently the sync should be performed, in seconds. On Android API level 24 and above, a minmam interval of 15 minutes is enforced. On previous versions, the minimum interval is 1 hour.