6
我正在尝试使用同步适配器执行周期同步。它可以手动同步,但不会定期。这是我从logcat的执行周期性同步时出错
Could not find class 'android.content.SyncRequest$Builder', referenced from method
com.example.user.sunshine.sync.SunshineSyncAdapter.configurePeriodicSync
下面得到的唯一的事情是我的代码:
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);
}
}
有谁知道为什么会这样,我应该如何去有关解决呢?