to top
Android APIs
public final class

SyncResult

extends Object
implements Parcelable
java.lang.Object
   ↳ android.content.SyncResult

Class Overview

This class is used to communicate the results of a sync operation to the SyncManager. Based on the values here the SyncManager will determine the disposition of the sync and whether or not a new sync operation needs to be scheduled in the future.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final SyncResult ALREADY_IN_PROGRESS This instance of a SyncResult is returned by the SyncAdapter in response to a sync request when a sync is already underway.
public static final Creator<SyncResult> CREATOR
public boolean databaseError Used to indicate that the SyncAdapter experienced a hard error due to an error it received from interacting with the storage later.
public long delayUntil Used to indicate to the SyncManager that future sync requests that match the request's Account and authority should be delayed at least this many seconds.
public boolean fullSyncRequested If set the SyncManager will request an immediate sync with the same Account and authority (but empty extras Bundle) as was used in the sync request.
public boolean moreRecordsToGet This field is ignored by the SyncManager.
public boolean partialSyncUnavailable This field is ignored by the SyncManager.
public final SyncStats stats Used to hold extras statistics about the sync operation.
public final boolean syncAlreadyInProgress Used to indicate that the SyncAdapter is already performing a sync operation, though not necessarily for the requested account and authority and that it wasn't able to process this request.
public boolean tooManyDeletions Used to indicate that the SyncAdapter determined that it would need to issue too many delete operations to the server in order to satisfy the request (as defined by the SyncAdapter).
public boolean tooManyRetries Used to indicate that the SyncAdapter experienced a hard error due to trying the same operation too many times (as defined by the SyncAdapter).
Public Constructors
SyncResult()
Create a "clean" SyncResult.
Public Methods
void clear()
Clears the SyncResult to a clean state.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
boolean hasError()
A convenience method for determining of the SyncResult indicates that an error occurred.
boolean hasHardError()
Convenience method for determining if the SyncResult indicates that a hard error occurred.
boolean hasSoftError()
Convenience method for determining if the SyncResult indicates that a soft error occurred.
boolean madeSomeProgress()
String toDebugString()
Generates a debugging string indicating the status.
String toString()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel(Parcel parcel, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final SyncResult ALREADY_IN_PROGRESS

Added in API level 5

This instance of a SyncResult is returned by the SyncAdapter in response to a sync request when a sync is already underway. The SyncManager will reschedule the sync request to try again later.

public static final Creator<SyncResult> CREATOR

Added in API level 5

public boolean databaseError

Added in API level 5

Used to indicate that the SyncAdapter experienced a hard error due to an error it received from interacting with the storage later. The SyncManager will record that the sync request failed and it will not reschedule the request.

public long delayUntil

Added in API level 8

Used to indicate to the SyncManager that future sync requests that match the request's Account and authority should be delayed at least this many seconds.

public boolean fullSyncRequested

Added in API level 5

If set the SyncManager will request an immediate sync with the same Account and authority (but empty extras Bundle) as was used in the sync request.

public boolean moreRecordsToGet

Added in API level 5

This field is ignored by the SyncManager.

public boolean partialSyncUnavailable

Added in API level 5

This field is ignored by the SyncManager.

public final SyncStats stats

Added in API level 5

Used to hold extras statistics about the sync operation. Some of these indicate that the sync request resulted in a hard or soft error, others are for purely informational purposes.

public final boolean syncAlreadyInProgress

Added in API level 5

Used to indicate that the SyncAdapter is already performing a sync operation, though not necessarily for the requested account and authority and that it wasn't able to process this request. The SyncManager will reschedule the request to run later.

public boolean tooManyDeletions

Added in API level 5

Used to indicate that the SyncAdapter determined that it would need to issue too many delete operations to the server in order to satisfy the request (as defined by the SyncAdapter). The SyncManager will record that the sync request failed and will cause a System Notification to be created asking the user what they want to do about this. It will give the user a chance to choose between (1) go ahead even with those deletes, (2) revert the deletes, or (3) take no action. If the user decides (1) or (2) the SyncManager will issue another sync request with either SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS or SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS set in the extras. It is then up to the SyncAdapter to decide how to honor that request.

public boolean tooManyRetries

Added in API level 5

Used to indicate that the SyncAdapter experienced a hard error due to trying the same operation too many times (as defined by the SyncAdapter). The SyncManager will record that the sync request failed and it will not reschedule the request.

Public Constructors

public SyncResult ()

Added in API level 5

Create a "clean" SyncResult. If this is returned without any changes then the SyncManager will consider the sync to have completed successfully. The various fields can be set by the SyncAdapter in order to give the SyncManager more information as to the disposition of the sync.

The errors are classified into two broad categories: hard errors and soft errors. Soft errors are retried with exponential backoff. Hard errors are not retried (except when the hard error is for a SYNC_EXTRAS_UPLOAD request, in which the request is retryed without the SYNC_EXTRAS_UPLOAD extra set). The SyncManager checks the type of error by calling hasHardError() and hasSoftError(). If both are true then the SyncManager treats it as a hard error, not a soft error.

Public Methods

public void clear ()

Added in API level 5

Clears the SyncResult to a clean state. Throws an UnsupportedOperationException if this is called when syncAlreadyInProgress is set.

public int describeContents ()

Added in API level 5

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public boolean hasError ()

Added in API level 5

A convenience method for determining of the SyncResult indicates that an error occurred.

Returns
  • true if either a soft or hard error occurred

public boolean hasHardError ()

Added in API level 5

Convenience method for determining if the SyncResult indicates that a hard error occurred. See SyncResult() for an explanation of what the SyncManager does when it sees a hard error.

A hard error is indicated when any of the following is true:

Returns
  • true if a hard error is indicated

public boolean hasSoftError ()

Added in API level 5

Convenience method for determining if the SyncResult indicates that a soft error occurred. See SyncResult() for an explanation of what the SyncManager does when it sees a soft error.

A soft error is indicated when any of the following is true:

Returns
  • true if a hard error is indicated

public boolean madeSomeProgress ()

Added in API level 5

public String toDebugString ()

Added in API level 5

Generates a debugging string indicating the status. The string consist of a sequence of code letter followed by the count. Code letters are f - fullSyncRequested, r - partialSyncUnavailable, X - hardError, e - numParseExceptions, c - numConflictDetectedExceptions, a - numAuthExceptions, D - tooManyDeletions, R - tooManyRetries, b - databaseError, x - softError, l - syncAlreadyInProgress, I - numIoExceptions

Returns
  • debugging string.

public String toString ()

Added in API level 5

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel parcel, int flags)

Added in API level 5

Flatten this object in to a Parcel.

Parameters
parcel The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.