Android's Intent Method for passing Java objects, androidintent

Source: Internet
Author: User

Android's Intent Method for passing Java objects, androidintent

In Android, Intent provides two methods to pass Java objects: one is to call the putSerializable (Key, Object) method of the Bundle Object 【See examples], The other is by calling the putParcelable (Key, Object) method of the Bundle Object 【See examples].

The first method requires that the passed Java object implement the Serializable interface -- the Serializable interface is a special interface of JavaSE. It is very easy to implement class serialization using this method. It is declared that the system will automatically serialize it.

The second method requires that the passed Java object implement the Parcelable interface -- The Parcelable interface is a special Android interface, this method is more efficient than Serializable interface implementation to achieve class serialization (using the Serializable interface to achieve serialization will produce a large number of temporary variables, resulting in frequent GC ), however, implementing the Parcelable interface is more complex than implementing the Serializable interface. We recommend implementing the Parcelable interface in terms of efficiency.

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: info-contact@alibabacloud.com 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.