I use SyncAdapter and GCM to notify my application of various types of changes on the backend server. For example, if change A occurs on the server, I do a push notification with the field change_a, which I pass to the SyncAdapter through ContentResolver.requestSync() . Thus, the SyncAdapter knows what needs to be synchronized with the server. Similarly, to change B, I send a field named change_b.
This works fine except for one use case. I send a change_a notification, it calls ContentResolver.requestSync() , but since there is no network availability, SyncAdapter is not called yet. If after that I send a change_b notification, ContentResolver.requestSync() is called again with a new field. And then, when the network is up, the SyncAdapter is SyncAdapter , but only with the last field change_b and, accordingly, it does not synchronize change A.
So basically ContentResolver.requestSync() cancels all previous calls to requestSync() that haven't activated SyncAdapter yet. SyncAdapter starts with the latest additions that have been sent.
One solution to this is to not distinguish between change A and change B and have the SyncAdapter synchronize everything. But it's expensive for bandwidth. I want to control what and when to synchronize. Is there something I could do to fix this (maybe a sync flag)?
source share