Share via


ContentResolver.AddPeriodicSync(Account, String, Bundle, Int64) Method

Definition

Specifies that a sync should be requested with the specified the account, authority, and extras at the given frequency.

[Android.Runtime.Register("addPeriodicSync", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;J)V", "")]
public static void AddPeriodicSync (Android.Accounts.Account? account, string? authority, Android.OS.Bundle? extras, long pollFrequency);
[<Android.Runtime.Register("addPeriodicSync", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;J)V", "")>]
static member AddPeriodicSync : Android.Accounts.Account * string * Android.OS.Bundle * int64 -> unit

Parameters

account
Account

the account to specify in the sync

authority
String

the provider to specify in the sync request

extras
Bundle

extra parameters to go along with the sync request

pollFrequency
Int64

how frequently the sync should be performed, in seconds. On Android API level 24 and above, a minimum interval of 15 minutes is enforced. On previous versions, the minimum interval is 1 hour.

Attributes

Exceptions

if an illegal extra was set or if any of the parameters are null.

Remarks

Specifies that a sync should be requested with the specified the account, authority, and extras at the given frequency. If there is already another periodic sync scheduled with the account, authority and extras then a new periodic sync won't be added, instead the frequency of the previous one will be updated.

These periodic syncs honor the "syncAutomatically" and "masterSyncAutomatically" settings. Although these sync are scheduled at the specified frequency, it may take longer for it to actually be started if other syncs are ahead of it in the sync operation queue. This means that the actual start time may drift.

Periodic syncs are not allowed to have any of #SYNC_EXTRAS_DO_NOT_RETRY, #SYNC_EXTRAS_IGNORE_BACKOFF, #SYNC_EXTRAS_IGNORE_SETTINGS, #SYNC_EXTRAS_INITIALIZE, #SYNC_EXTRAS_FORCE, #SYNC_EXTRAS_EXPEDITED, #SYNC_EXTRAS_MANUAL, #SYNC_EXTRAS_SCHEDULE_AS_EXPEDITED_JOB set to true. If any are supplied then an IllegalArgumentException will be thrown.

This method requires the caller to hold the permission android.Manifest.permission#WRITE_SYNC_SETTINGS.

The bundle for a periodic sync can be queried by applications with the correct permissions using ContentResolver#getPeriodicSyncs(Account account, String provider), so no sensitive data should be transferred here.

Java documentation for android.content.ContentResolver.addPeriodicSync(android.accounts.Account, java.lang.String, android.os.Bundle, long).

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.

Applies to