How do parcelable in Android know which variable to read in its constructor? -
you can see code below, parcel don't read key return value. how know read , put variable somestring1
or somestring2
, on?
public someobject(parcel in) { this.somestring1 = in.readstring(); this.somestring2 = in.readstring(); this.someint = in.readint(); this.somestring3 = in.readstring(); this.someint2 = in.readint(); }
what if put way. following code become error, because change order read it?
public someobject(parcel in) { this.somestring3 = in.readstring(); this.someint2 = in.readint(); this.somestring1 = in.readstring(); this.somestring2 = in.readstring(); this.someint = in.readint(); }
yes, changing order cause issues. values written sequentially, whatever order write fields out in writetoparcel()
, must read them in in same order when reading parcel
.
Comments
Post a Comment