0

I've implemented SyncAdapter, with sync frequency as 10 seconds. But while running the application, this sync frequency is automatically updated to 900 seconds.

Account Creation code:

public static void createSyncAccount(Context c) {
        boolean created = false;

        Account account = getAccount();
        AccountManager manager = (AccountManager)c.getSystemService(Context.ACCOUNT_SERVICE);

        if (manager != null && manager.addAccountExplicitly(account, null, null)) {
            final String AUTHORITY = UserIntakeContract.CONTENT_AUTHORITY;
            final long SYNC_FREQUENCY = 10; // (seconds)

            ContentResolver.setIsSyncable(account, AUTHORITY, 1);
            ContentResolver.setSyncAutomatically(account, AUTHORITY, true);
            ContentResolver.addPeriodicSync(account, AUTHORITY, new Bundle(), SYNC_FREQUENCY);
            created = true;
        }

        if (created) {
            SyncAdapter.performSync();
        }
    }

Log Trace:

03-13 10:00:16.902 18073-18094/system_process W/ContentService: 
Requested poll frequency of 10 seconds being rounded up to 900s.

But I'm not able to find any resource or documentation stating minimum poll frequency as 15 minutes (900 seconds).

Can anyone provide some authentic resource or documentation or explanation?

Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126

2 Answers2

0

Did you check the documentation of "ContentResolver.addPeriodicSync". There is poll frequency documentation with the description: long: how frequently the sync should be performed, in seconds. A minimum value of 1 hour is enforced. Maybe due to this enforcement this change is happening.

Ram Koti
  • 2,203
  • 7
  • 26
  • 36
Qandil Tariq
  • 539
  • 1
  • 3
  • 15
0

Looks like you are trying to set time period beyond limit.

After looking at source:

https://android.googlesource.com/platform/frameworks/base/+/b267554/services/java/com/android/server/content/ContentService.java#415

Minimum time period that can be set varies from version to version.

Chintan Soni
  • 24,761
  • 25
  • 106
  • 174