所以我试图将我通过意图创建的类的实例传递给新的活动。
public class Room implements Serializable{
/**
*
*/
private static final long serialVersionUID = 6857044522819206055L;
int roomID;
String roomName;
ArrayList<MarkerHolder> markerHolders = new ArrayList<MarkerHolder>();
public int getRoomID() {
return roomID;
}
public void setRoomID(int roomID) {
this.roomID = roomID;
}
public String getRoomName() {
return roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public ArrayList<MarkerHolder> getMarkerHolders() {
return markerHolders;
}
public void setMarkerHolders(ArrayList<MarkerHolder> markerHolders) {
this.markerHolders = markerHolders;
}
}
public class MarkerHolder implements Serializable{
/**
*
*/
private static final long serialVersionUID = -7334724625702415322L;
String marker;
String markerTag;
public String getMarker() {
return marker;
}
public void setMarker(String marker) {
this.marker = marker;
}
public String getMarkerTag() {
return markerTag;
}
public void setMarkerTag(String markerTag) {
this.markerTag = markerTag;
}
}
我试着通过那门课
Intent svc = new Intent(this, RoomUploader.class);
svc.putExtra("room", room);
try{
startService(svc);
}catch (Exception e){
e.printStackTrace();
}
而且我不断收到一个我无法弄清楚的不可序列化异常。这两个类都实现了可序列化并具有序列 ID。成员变量只是字符串、整数和另一个类的数组,该类也可序列化,仅包含字符串。据我所知,所有这些东西都应该是可序列化的,还有什么可能导致这个错误?提前致谢。