Question

In my AccountAuthenticatorActivity I try setup sync-options for an Account after addAccountExplicitly with following lines:

ContentResolver.setIsSyncable(account, authority, 1);
ContentResolver.setSyncAutomatically(account, authority, true);
int seconds = getResources().getInteger(R.integer.syncFrequencySeconds);
ContentResolver.addPeriodicSync(account, authority, new Bundle(), seconds);

syncFrequencySeconds is set to 86400 (every 24 hours). But my sync-adapter is still triggered every minute. What am I doing wrong? (sync itselfs works without any problems)

Was it helpful?

Solution

Solved it myself: the sync-adapter repeats when the SyncResult.stats do not match with the ContentResolver-Operations. As they matched, sync is triggered as expected.

Update: another issue was, that I called ContentResolver.notifyUpdate during sync-operation. removed that, and it was fine.

OTHER TIPS

My SyncAdapter was running every minute, not respecting the pollFrequency interval. I was using only queries to send local data to a remote server (on the SyncAdapter). I was not updating any local data on the SyncAdapter.

But my local data was being updated at very short intervals (receiving data from a BLE device) using another service.

To solve this issue, I had to change all notifyChange calls on my data provider to include the additional parameter syncToNetwork: false (check notifyChange documentation).

//getContext().getContentResolver().notifyChange(uri, null);
getContext().getContentResolver().notifyChange(uri, null, false);

This change did not affect my CursorAdapter used in the Activity to show the data as soon as I update the tables.

Assigning proper values to syncResult.stats did not solved my problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top