4

I understand that autosync occurs 30 seconds after content is modified. Watching logcat for fat longer then that proves that the autosync does not occur. Atleast, not for my custom SyncAdapter.

UserProvider:

<provider android:name="nl.providers.UserProvider" 
    android:authorities="nl.providers.UserProvider" 
    android:enabled="true" android:label="Users" />

UserSyncAdapter:

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" 
    android:contentAuthority="nl.providers.UserProvider"
    android:accountType="nl.account" 
    android:supportsUploading="false" 
    android:userVisible="true" />

Launcher:

ContentResolver.setIsSyncable(account, "nl.providers.UserProvider", 1);
ContentResolver.setSyncAutomatically(account, "nl.providers.UserProvider", true);

Am I missing something? Or can anyone give me more information on the subject to help my search?

Pim Reijersen
  • 1,123
  • 9
  • 33
  • 2
    [StackOverflow: Why does ContentResolver.requestSync not trigger a sync?][1] provides all the steps you need to get lined up to get sync to go. [1]: http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync?rq=1 – jcwenger Jun 19 '12 at 18:59

4 Answers4

3

There's no set time delay for when a sync occurs. It can be sooner or later depending on other activity on the device.

It's not enough to modify content. Are you calling notifyChange() ? for example in your ContentProvider after your insert,update or delete:

getContext().getContentResolver().notifyChange(rowUri, null, true);

Also make sure that in your Accounts & Sync settings on the device or emulator you're testing that syncing is actually enabled.

Hope that helps someone :)

Joachim
  • 901
  • 8
  • 18
  • Thanks, .notifyChange() was what I was missing to get the sync to fire automatically when the network state changes. – etherton Apr 01 '15 at 20:53
0

The reasons I can think:

1) You did not add an account for that SyncAdapter (do it in Account&Sync)

2) There is no internet connection on your device

kingston
  • 11,053
  • 14
  • 62
  • 116
0

Check the system account settings for any sync errors. These can occur if your sync added exceptions to the sync result stats, which could cause it to wait longer to sync again. You can also test with "Sync now" from the menu.

Eric Woodruff
  • 6,380
  • 3
  • 36
  • 33
0

The reason could be because you are setting android:supportsUploading="false" and you need to set it to true like android:supportsUploading="true" then the adapter can sync with the network.

epool
  • 6,710
  • 7
  • 38
  • 43