FileDocCategorySizeDatePackage
SyncContext.javaAPI DocAndroid 1.5 API2262Wed May 06 22:41:54 BST 2009android.content

SyncContext

public class SyncContext extends Object
hide

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


       
        mSyncContext = syncContextInterface;
        mLastHeartbeatSendTime = 0;
    
Methods Summary
public ISyncContextgetISyncContext()

        return mSyncContext;
    
public voidonFinished(SyncResult result)

        try {
            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

        updateHeartbeat();
    
public 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;
            mSyncContext.sendHeartbeat();
        } catch (RemoteException e) {
            // this should never happen
        }