Android App Sync Schedule

I have my Android sync database sync app configured. Most of the internals were taken from the sync adapter demo. I have a very simple question though, when does this app sync? I know google services will sync when they get the tickle of the web, is this the case with the services you've set up to sync?


source to share

2 answers

Since Amorgos mentioned the tickles you mentioned are C2DM push messages. If it's important to instantly sync changes after they're done in the cloud, you should consider implementing them. You can go here for more information.

To request a sync operation, the class you should look at is ContentResolver . If you want to sync a Sync call request (account account, String permissions, advanced options) (use it for sync button or similar). To sync changes to ContentProvider, you can call

getContentResolver().notifyChange(CONTENT_URI, null, true);  


after the record is created / modified (for changes that should not be synchronized, replace true with false and no synchronization will be activated). If android: supportsUploading in your SyncAdapter xml file is set to true, this will automatically trigger 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 your local changes to the cloud and not ask for anything.

If you just want to sync every hour, use addPeriodicSync (account account, String permissions, optional components, long polling rate).

You can also use ContentResolver to read / set if it should sync or not (value specified in device settings in accounts and sync). The methods are getIsSyncable (...) and setIsSyncable (...).

Hope this helps you.

Edit: This also describes the really good processes: Why is ContentResolver.requestSync not triggering sync?



It all depends on the requirements of your application. If you are syncing data that is not critical that the user knows about right away, then syncing with the OS may be sufficient. (The contact list is a perfect example of this)

If your app relies on more real-time notification, you should consider using C2DM push notifications to initiate the sync process. You can raise C2DM messages when the server changes data and sends it to your device. The app will then start the sync process based on the content of this message. (C2DM is network sensitiveness that you turn to like Gmail for example)

It is up to you to architect your application to decide when to effectively initiate this sync using whatever way you decide. All applications have different synchronization requirements.



All Articles