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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -