Example usage for android.content ContentResolver requestSync

List of usage examples for android.content ContentResolver requestSync

Introduction

In this page you can find the example usage for android.content ContentResolver requestSync.

Prototype

public static void requestSync(SyncRequest request) 

Source Link

Document

Register a sync with the SyncManager.

Usage

From source file:com.glandorf1.joe.wsprnetviewer.app.sync.WsprNetViewerSyncAdapter.java

/**
 * Helper method to schedule the sync adapter periodic execution
 *//*from  ww w. j  a v a 2 s .com*/
public static void configurePeriodicSync(Context context, int syncInterval, int flexTime) {
    Account account = getSyncAccount(context);
    String authority = context.getString(R.string.content_authority);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // we can enable inexact timers in our periodic sync
        SyncRequest request = new SyncRequest.Builder().syncPeriodic(syncInterval, flexTime)
                .setSyncAdapter(account, authority).build();
        ContentResolver.requestSync(request);
    } else {
        ContentResolver.addPeriodicSync(account, authority, new Bundle(), syncInterval);
    }
}