我想将数据传递给我的服务类。我的模型使用implements Serializable创建。
Runnable class
Bundle bundle = new Bundle();
Intent serviceIntent = new Intent(mContext,InitLocationsOnStartup.class);
List<StationViewModel> stationList = new ArrayList<StationViewModel>();
......
....
bundle.putSerializable("stations",stationList); //Wrong 2nd argument type. Found: 'java.util.List<StationViewModel>', required: 'java.io.Serializable'
或
serviceIntent.putExtra("stations",stationList);//Cannot resolve method 'putExtra(java.lang.String, java.util.List<StationViewModel>
如何传递数据?
答案 0 :(得分:1)
您需要 stationList
List
bundle.putSerializable("stations", (Serializable) stationList);
implements
或强>
StationViewModel
可序列化到您的 public class StationViewModel implements Serializable
类
<强> var divs = document.getElementsByClassName('block-text');
var allDivsHeight = [];
for (i = 0; i < divs.length; i++) {
allDivsHeight.push(divs[i].offsetHeight);
}
console.log(allDivsHeight);//just for debugging
console.log(Math.max(...allDivsHeight))
强>
答案 1 :(得分:1)
尝试序列化您的数据
bundle.putSerializable("stations", (Serializable) stationList);
或
Intent serviceIntent = new Intent(YourActivity.this, bgservice.class);
serviceIntent.putExtra("stations", (Serializable) stationList);
this.startService(serviceIntent);