I am trying to perform a period sync using a sync adapter. It syncs fine 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 happens and how I should go about resolving it?