I have setup an application to perform syncing with the Android syncing framework. Most of the internals have been taken from the sync adapter demo. I have a very simple question though, when does this app sync? I know that the google services will sync when they receive a network “tickle” is this also the case with services that you have setup to sync?
I have setup an application to perform syncing with the Android syncing framework. Most
Share
As Amorgos mentioned those tickles you mentioned are C2DM push messages. If it is important to sync changes instantly after they are made in the cloud you should think about implementing them. You can go here for more information.
For requesting a sync operation, the class you have to look at is the ContentResolver. If you want to sync call requestSync(Account account, String authority, Bundle extras) (use it for a sync now button or similar). To sync changes in your ContentProvider you can call
after creating/changing the entry (for changes that shouldn’t be synced replace the true with false and no sync will be triggered). If android:supportsUploading in your SyncAdapter’s xml file is set to true, this will automatically trigger a sync. In this case the Bundle in your SyncAdapter contains a Boolean value with the key ContentResolver.SYNC_EXTRAS_UPLOAD which is true. You can use it to just sync local changes to the cloud and not querying anything.
If you want just to sync each hour use addPeriodicSync(Account account, String authority, Bundle extras, long pollFrequency).
You can also use the ContentResolver to read/set if it should sync or not (the value which is shown in the device settings at accounts & sync). The methods are getIsSyncable(…) and setIsSyncable(…).
I hope this can help you.
Edit:
This also describes the processes really good: Why does ContentResolver.requestSync not trigger a sync?