android:每5分钟执行一次定期同步

时间:2019-02-14 18:21:48

标签: android android-syncadapter periodic-task

在我们的应用中,我们使用同步适配器进行定期同步。

Account account = getAccount(context);         

// Turn on automatic syncing for the account and authority
ContentResolver.setSyncAutomatically(account, SyncAdapter.AUTHORITY, true);
ContentResolver.setIsSyncable(account, SyncAdapter.AUTHORITY, 1);   

removePeriodicSyncs(account);            
ContentResolver.addPeriodicSync(account, SyncAdapter.AUTHORITY,
Bundle.EMPTY, context.getResources().getInteger(R.integer.syncIntervalSeconds));

最新发现,对于Android N之后的android版本,最小定期间隔为15分钟,并且每次15分钟(而不是5分钟)仅发生一次响声。解决此问题的正确方法是什么

0 个答案:

没有答案