Language

SyncRequest.Builder.SyncPeriodic(Int64, Int64) Method

Definition

Configures a periodic sync request.

[Android.Runtime.Register("syncPeriodic", "(JJ)Landroid/content/SyncRequest$Builder;", "GetSyncPeriodic_JJHandler")]
public virtual Android.Content.SyncRequest.Builder? SyncPeriodic(long pollFrequency, long beforeSeconds);
[<Android.Runtime.Register("syncPeriodic", "(JJ)Landroid/content/SyncRequest$Builder;", "GetSyncPeriodic_JJHandler")>]
abstract member SyncPeriodic : int64 * int64 -> Android.Content.SyncRequest.Builder
override this.SyncPeriodic : int64 * int64 -> Android.Content.SyncRequest.Builder

Parameters

pollFrequency
Int64

The requested time in seconds between periodic syncs. The system may round up short periods.

beforeSeconds
Int64

The flex time in seconds before pollFrequency during which the sync may take place. The builder rejects values greater than pollFrequency.

Returns

This builder.

Attributes

Remarks

Call either this method or SyncOnce() on the builder. A builder cannot be reused for a one-time sync after it has been configured for a periodic sync; doing so throws an IllegalArgumentException. Periodic syncs are identified by their account, provider authority, and extras. Applications with the correct permissions can query the extras, so do not include sensitive data.

The following examples request a sync every five hours with 20 minutes of flex, and a sync every hour with one hour of flex:

var fiveHourBuilder = new SyncRequest.Builder();
fiveHourBuilder.SyncPeriodic(5 * 60 * 60, 20 * 60);
var hourlyBuilder = new SyncRequest.Builder();
hourlyBuilder.SyncPeriodic(60 * 60, 60 * 60);

Periodic syncs cannot have these extras set to true: SyncExtrasDoNotRetry, SyncExtrasIgnoreBackoff, SyncExtrasIgnoreSettings, SyncExtrasInitialize, SyncExtrasForce, SyncExtrasExpedited, SyncExtrasManual, and SyncExtrasScheduleAsExpeditedJob. The builder throws an IllegalArgumentException when it validates these extras.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Java documentation for android.content.SyncRequest.Builder.syncPeriodic(long, long).

Applies to