Think of parceling as a recursive process. Given an arbitrary object that implements the Parcelable
interface, the parcel process calls object.writeToParcel()
. In this method again, you need to parcel all fields of object, where they are either natively parcelable types (int, bool, String, List, ...) or again parcelables. If they are parcelables, the writeToParcel()
method is called on them. You do this until you reach natively parcelable types in every recursion branch.
Having a look at your code, with dest.writeList((ArrayList<Rule>)rateRule.getRules());
you rely on the fact that there is a method that seems to wrote a list to a parcel. But there is the precondition that the type of the list elements is again parcelable, which is not the case here.
You need to make Rule
parcelable, thus you need to make Room
parcelable, thus you need to make Galery
parcelable, ...
In general, have a look at the class you want to be parceled and then check top-down for each field's class whether it is already parcelable.