FileDocCategorySizeDatePackage
SyncContext.javaAPI DocAndroid 5.1 API2481Thu Mar 12 22:22:10 GMT 2015android.content

SyncContext

public class SyncContext extends Object

Fields Summary
private ISyncContext
mSyncContext
private long
mLastHeartbeatSendTime
private static final long
HEARTBEAT_SEND_INTERVAL_IN_MS
Constructors Summary
public SyncContext(ISyncContext syncContextInterface)

hide


          
       
        mSyncContext = syncContextInterface;
        mLastHeartbeatSendTime = 0;
    
Methods Summary
public android.os.IBindergetSyncContextBinder()

        return (mSyncContext == null) ? null : mSyncContext.asBinder();
    
public voidonFinished(SyncResult result)

        try {
            if (mSyncContext != null) {
                mSyncContext.onFinished(result);
            }
        } catch (RemoteException e) {
            // this should never happen
        }
    
public voidsetStatusText(java.lang.String message)
Call to update the status text for this sync. This internally invokes {@link #updateHeartbeat}, so it also takes the place of a call to that.

param
message the current status message for this sync
hide

        updateHeartbeat();
    
private voidupdateHeartbeat()
Call to indicate that the SyncAdapter is making progress. E.g., if this SyncAdapter downloads or sends records to/from the server, this may be called after each record is downloaded or uploaded.

        final long now = SystemClock.elapsedRealtime();
        if (now < mLastHeartbeatSendTime + HEARTBEAT_SEND_INTERVAL_IN_MS) return;
        try {
            mLastHeartbeatSendTime = now;
            if (mSyncContext != null) {
                mSyncContext.sendHeartbeat();
            }
        } catch (RemoteException e) {
            // this should never happen
        }