FileDocCategorySizeDatePackage
SyncRequest.javaAPI DocAndroid 5.1 API20951Thu Mar 12 22:22:10 GMT 2015android.content

SyncRequest

public class SyncRequest extends Object implements android.os.Parcelable
Convenience class to construct sync requests. See {@link android.content.SyncRequest.Builder} for an explanation of the various functions. The resulting object is passed through to the framework via {@link android.content.ContentResolver#requestSync(SyncRequest)}.

Fields Summary
private static final String
TAG
private final android.accounts.Account
mAccountToSync
Account to pass to the sync adapter. Can be null.
private final String
mAuthority
Authority string that corresponds to a ContentProvider.
private final android.os.Bundle
mExtras
Bundle containing user info as well as sync settings.
private final boolean
mDisallowMetered
Don't allow this sync request on metered networks.
private final long
mSyncFlexTimeSecs
Amount of time before {@link #mSyncRunTimeSecs} from which the sync may optionally be started.
private final long
mSyncRunTimeSecs
Specifies a point in the future at which the sync must have been scheduled to run.
private final boolean
mIsPeriodic
Periodic versus one-off.
private final boolean
mIsAuthority
Service versus provider.
private final boolean
mIsExpedited
Sync should be run in lieu of other syncs.
public static final Creator
CREATOR
Constructors Summary
private SyncRequest(android.os.Parcel in)

        mExtras = in.readBundle();
        mSyncFlexTimeSecs = in.readLong();
        mSyncRunTimeSecs = in.readLong();
        mIsPeriodic = (in.readInt() != 0);
        mDisallowMetered = (in.readInt() != 0);
        mIsAuthority = (in.readInt() != 0);
        mIsExpedited = (in.readInt() != 0);
        mAccountToSync = in.readParcelable(null);
        mAuthority = in.readString();
    
protected SyncRequest(Builder b)
{@hide} Protected ctor to instantiate anonymous SyncRequest.

        mSyncFlexTimeSecs = b.mSyncFlexTimeSecs;
        mSyncRunTimeSecs = b.mSyncRunTimeSecs;
        mAccountToSync = b.mAccount;
        mAuthority = b.mAuthority;
        mIsPeriodic = (b.mSyncType == Builder.SYNC_TYPE_PERIODIC);
        mIsAuthority = (b.mSyncTarget == Builder.SYNC_TARGET_ADAPTER);
        mIsExpedited = b.mExpedited;
        mExtras = new Bundle(b.mCustomExtras);
        // For now we merge the sync config extras & the custom extras into one bundle.
        // TODO: pass the configuration extras through separately.
        mExtras.putAll(b.mSyncConfigExtras);
        mDisallowMetered = b.mDisallowMetered;
    
Methods Summary
public intdescribeContents()


    
       
        return 0;
    
public android.accounts.AccountgetAccount()
{@hide}

return
account object for this sync.
throws
IllegalArgumentException if this function is called for a request that targets a sync service.

        return mAccountToSync;
    
public android.os.BundlegetBundle()
{@hide} Retrieve bundle for this SyncRequest. Will not be null.

        return mExtras;
    
public java.lang.StringgetProvider()
{@hide}

return
provider for this sync.
throws
IllegalArgumentException if this function is called for a request that targets a sync service.

        return mAuthority;
    
public longgetSyncFlexTime()
{@hide}

return
the earliest point in time that this sync can be scheduled.

        return mSyncFlexTimeSecs;
    
public longgetSyncRunTime()
{@hide}

return
the last point in time at which this sync must scheduled.

        return mSyncRunTimeSecs;
    
public booleanisExpedited()
{@hide}

return
whether this sync is expedited.

        return mIsExpedited;
    
public booleanisPeriodic()
{@hide}

return
whether this sync is periodic or one-time. A Sync Request must be either one of these or an InvalidStateException will be thrown in Builder.build().


                                                   
       
        return mIsPeriodic;
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeBundle(mExtras);
        parcel.writeLong(mSyncFlexTimeSecs);
        parcel.writeLong(mSyncRunTimeSecs);
        parcel.writeInt((mIsPeriodic ? 1 : 0));
        parcel.writeInt((mDisallowMetered ? 1 : 0));
        parcel.writeInt((mIsAuthority ? 1 : 0));
        parcel.writeInt((mIsExpedited? 1 : 0));
        parcel.writeParcelable(mAccountToSync, flags);
        parcel.writeString(mAuthority);