Tôi đang cố gắng thực hiện đồng bộ hóa thời gian bằng bộ điều hợp đồng bộ hóa. Nó đồng bộ tốt bằng tay nhưng không định kỳ. Đây là điều duy nhất tôi nhận được từ logcatLỗi khi thực hiện đồng bộ hóa định kỳ
Could not find class 'android.content.SyncRequest$Builder', referenced from method
com.example.user.sunshine.sync.SunshineSyncAdapter.configurePeriodicSync
Dưới đây là mã của tôi:
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);
}
}
Có ai biết tại sao điều này xảy ra và làm thế nào tôi nên đi về việc giải quyết nó?