addPeriodicSync用于触发初始同步

时间:2014-04-20 16:27:34

标签: android android-contentresolver

是否可以在创建定期同步后立即触发同步过程?

ContentResolver.setSyncAutomatically(account, DbContentProvider.AUTHORITY, true);
// Make this run a sync job...
ContentResolver.addPeriodicSync(account, DbContentProvider.AUTHORITY, bundle, 60);

1 个答案:

答案 0 :(得分:0)

这将触发同步立即发生

        Bundle bundle = new Bundle();
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
        ContentResolver.requestSync(account, DbContentProvider.AUTHORITY, bundle);