I am trying to perform period synchronization using a synchronization adapter. Synchronization is performed manually, but not periodically. This is the only thing I got from logcat
Could not find class 'android.content.SyncRequest$Builder', referenced from method com.example.user.sunshine.sync.SunshineSyncAdapter.configurePeriodicSync
Below is my code:
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) { SyncRequest request = new SyncRequest.Builder(). syncPeriodic(syncInterval, flexTime). setSyncAdapter(account, authority).build(); ContentResolver.requestSync(request); } else { ContentResolver.addPeriodicSync(account, authority, new Bundle(), syncInterval); } }
Does anyone know why this is happening and how I should solve it?
source share