我正在实施一个SyncAdapter
,我需要在一天内同步几次,但我还需要onPerformSync
在午夜触发同步。
ContentResolver.setIsSyncable(account, URIBuilder.AUTHORITY, 1);
Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false);
extras.putBoolean(ContentResolver.SYNC_EXTRAS_DO_NOT_RETRY, false);
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
ContentResolver.addPeriodicSync(account,
URIBuilder.AUTHORITY,
extras, 15000);
ContentResolver.setSyncAutomatically(account, URIBuilder.AUTHORITY, true);
ContentResolver.requestSync(account, URIBuilder.AUTHORITY, extras);