从Android 5.0开始,以下代码失败,并显示“错误解除捆绑”错误。

SyncRequest request = new SyncRequest.Builder()
.syncPeriodic(syncInterval, flexTime)
.setSyncAdapter(account, MyContract.CONTENT_AUTHORITY).
build();

最佳答案

在棒棒糖中,必须存在Bundle才能构建请求。用此代码替换以设置捆绑包。

SyncRequest request = new SyncRequest.Builder()
.syncPeriodic(syncInterval, flexTime)
.setSyncAdapter(account, MyContract.CONTENT_AUTHORITY)
.setExtras(new Bundle()).
build();

10-08 16:34