When using an android bundle, why does a serialised stack deserialise as an ArrayList?

后端 未结 3 931
醉酒成梦
醉酒成梦 2020-12-31 12:02

Serialisation:

Bundle activityArguments = new Bundle();
Stack> wizardSteps = new Stack

        
3条回答
  •  被撕碎了的回忆
    2020-12-31 12:55

    Its known bug. I surprise that it still exists.

    Use generic container like:

    public class SerializableHolder implements Serializable {
    private Serializable content;
    public Serializable get() {
        return content;
    }
    public SerializableHolder(Serializable content) {
        this.content = content;
     }
    }
    

    If you use GSON library, convert your Stack to String and use as single String for Bundle without Serialize. It should work.

提交回复
热议问题