मैं एंड्रॉयड/जावा में स्थान का एक उपवर्ग की क्रमबद्धता के साथ एक brickwall मार रहागैर serializable माता पिता वर्ग
स्थान के Serializable उपवर्ग serializable नहीं है। मेरे पास FALocation नामक पहला उप-वर्ग है जिसमें कोई आवृत्ति चर नहीं है। मैंने इसे धारावाहिक घोषित कर दिया है।
public class Waypoint extends FALocation implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/* Class variables *******************************************************/
private static int CLASS_VERSION=1; //Used to version parcels
/* Instance variables ****************************************************/
private transient String type=DataHelper.PT_TYPE_US;
private transient String country;
private transient String name=null;
private transient String description=null;
private transient int elevation = 0;
private transient int population = 0; // Afterthought, added to match the DB structure
/* Constructors **********************************************************/
public Waypoint() {
super();
}
public Waypoint(double lat, double lon, String name, String description) {
super(lat, lon);
this.setName(name);
this.setDescription(description);
}
public Waypoint(Location l) {
super(l);
}
public Waypoint(String provider) {
super(provider);
}
/* Implementing serializable */
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
Log.v("DroidFA", "Serialising \"%s\" (v%d).", Waypoint.class.getSimpleName(), CLASS_VERSION);
out.writeInt(CLASS_VERSION);
out.writeObject(type);
out.writeObject(country);
out.writeObject(name);
out.writeObject(description);
out.writeInt(elevation);
out.writeInt(population);
}
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
int serialClassVersion = in.readInt();
Log.v("DroidFA", "Deserialising \"%s\" (v%d).", Waypoint.class.getSimpleName(),serialClassVersion);
type = (String) in.readObject();
country = (String) in.readObject();
name = (String) in.readObject();
description = (String) in.readObject();
elevation = in.readInt();
population = in.readInt();
}
}
क्रमबद्धता ठीक काम करता है:
तो मैं एक द्वितीय श्रेणी बुलाया वेपॉइंट है कि इस तरह दिखता है।
Deseriamization पैदा करता followwing अपवाद (पैर वस्तु एक वेपॉइंट शामिल हैं) .:
10-05 13:50:35.259: WARN/System.err(7867): java.io.InvalidClassException: android.location.Location; IllegalAccessException
10-05 13:50:35.267: WARN/System.err(7867): at java.io.ObjectInputStream.resolveConstructorClass(ObjectInputStream.java:2010)
10-05 13:50:35.267: WARN/System.err(7867): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2095)
10-05 13:50:35.267: WARN/System.err(7867): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:929)
10-05 13:50:35.267: WARN/System.err(7867): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2285)
10-05 13:50:35.278: WARN/System.err(7867): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2240)
10-05 13:50:35.278: WARN/System.err(7867): at com.droidfa.navigation.Leg.readObject(Leg.java:262)
.../...
ऐसा लगता है कि समस्या कहीं और है। com.droidfa.navigation.Leg.readObject (Leg.java 32062) –
लेग लाइन 262 है: "से = (Waypoint) in.readObject();" जहां वह समस्या वास्तव में निहित है;)। – jmc34