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);
}
}
有誰知道爲什麼會這樣,我應該如何去有關解決呢?