Very detailed Android serialization process parcelable_android

Source: Internet
Author: User
Tags int size serialization stub

Directly on the code: the comments are written very clearly.

public class Entry implements parcelable{public int userID; public String username; public Boolean ismale; ook;//serialization objects can be nested, provided that the objects of the 2 classes are returned 0 in almost all cases, regardless of @Override public int describecontents () {return 0;}//Serialization object, Writes an object to the serial Number data structure//flags: Most cases are 0 @Override public void Writetoparcel (Parcel out, int flags) {out.writeint (UserID); Out.writ
Estring (username);
Out.writeint (Ismale 1:0);
Out.writeparcelable (book, 0);
Out.writelist (list) can also be serial number list and map, provided that the list and map inside the data is a serial number of//Out.writemap (map); Public Entry (int userid,string username,boolean ismale) {this.userid = UserID; this.username = username; This.ismale =
Ismale; ///deserialization public static final parcelable.creator<entry> Creator = new creator<entry> () {//Create the original object array of the specified length @Overr IDE public entry[] NewArray (int size) {//TODO auto-generated method stub return new Entry[size]///Create the original object from the object after the serial number @O Verride public Entry Createfromparcel (Parcel source) {//TODO auto-generated method stub return new Entry (source);
Create the original object from the object after the serial number private Entry (Parcel in) {UserID = In.readint (); username = in.readstring (); Ismale = In.readint () = 1;
In.readparcelable (Thread.CurrentThread (). Getcontextclassloader ());


The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.