2

I have a sync adapter running periodically to upload/download data to a server.

Despite the sync completing successfully, the Android sync manager is continually rescheduling the sync, even when no work was actually done as there was nothing new to sync.

Examining SyncResult object:

SyncResult.toDebugString() returns empty string
SyncResult.madeSomeProgress() returns false if nothing changed or true if we made some changes (as to be expected)
SyncResult.hasError() returns false

It's a fairly standard implementation of a Sync Service / Adapter so the behaviour is rather strange. Removing all code from onPerformSync results in a successful sync.

It seems like something is happening during the sync process which is causing the Sync Manager to think the sync failed, even when the result says otherwise, can anyone advise any further checks or a solution to this?

Philio
  • 3,675
  • 1
  • 23
  • 33
  • 2
    Are you calling `ContentResolver.notifyChange()` from your `ContentProvider`? If you are you should set third parameter `syncToNetwork` to `false` when you are inside `SyncAdapter`. – Blaz Feb 06 '14 at 10:25
  • Thanks for your suggestion, we were auto notifying all changes in the content provider (including to the table that's used for sync progress) and disabling for this table did the trick! – Philio Feb 06 '14 at 10:39
  • Good question, this is a common thing people run into and is very poorly documented. Voted to close with a reference to an earlier question that provides a longer answer with full details on how to implement this to not loop. Please don't take it personally, just wanted to tidy up the open questions list and provide a link to a full answer. :) – jcwenger Feb 25 '14 at 14:56

0 Answers0