I have 3 classes
@Parcelize
open class Parent():Parcelable
data class Child1():Parent
data class Child2():Parent
I want to pass data from one activity to another in container class which is
class Container(){
var obj:Parent
}
The problem is that even if I set the obj as Child1(or 2) in first activity, in second activity I can't get obj as Child, I can only get as Parent. How get obj as defined type?
Simply mark the Parent class as sealed. This way, you can ensure that the subclasses are known and can be properly handled during parcelization