It seems I drew the wrong conclusions. Actually, after some further testing, if requestSync()
is called with different extras, SyncAdapter
is called several times, for each different Bundle.
My problem was somewhere else. When I would receive a push notification, I would schedule an alarm to trigger the sync request and I would use a PendingIntent
with the flag PendingIntent.FLAG_CANCEL_CURRENT
, which meant that if another push notification came before the alarm went off, the alarm would be overwritten with the new data. And so, if the device was offline, when it came online, it received all the pending push notifications and there would be only one alarm set with the data from the most recent push notification.
The way I solved this problem, is by setting a different action on each PendingIntent so that setting a new alarm of the same type doesn't overwrite the other types of alarms.
And a improvement to this would be to add a collapse_key for each type of sync so that only one of each kind of push notification gets delivered to the device.