Professional Documents
Culture Documents
Reading from a Parcel: Here, you add a second constructor (as opposed to the
primary constructor in the class declaration) so a TaskList object can be created
from a passed-in Parcel.
The constructor grabs the values from the Parcel for the title (by calling
readString on the Parcel) and the list of tasks (by calling
createStringArrayList on the Parcel), then passes them into the primary
constructor using this().
4. Calling your constructor: In the CREATOR companion object, you override the
interface function createFromParcel, and pass the parcel you get from this
function along to the second constructor you just created, giving back a nice new
TaskList with all of the data from the Parcel.
With the Parcelable interface implemented, any TaskList can be passed through an
Intent.