Ways to pass Java objects intent in Android

Source: Internet
Author: User

There are two ways to pass Java objects in Android intent: first, by calling the Putserializable (Key,object) method of the Bundle object " See Example ", The other is by calling the Putparcelable (Key,object) method of the Bundle object " See Example ".

The first method requires the delivery of the Java object implementation serializable interface--serializable interface is javase specific interface, using this method to implement the serialization of the class is very simple, declare that the system will automatically serialize it.

The second method requires that the passed Java object implement the Parcelable interface--parcelable interface is an Android-specific interface, Using this method is better than implementing the serializable interface to achieve the serialization efficiency of the class (using the Serializable interface to achieve serialization will produce a large number of temporary variables, resulting in frequent GC), But the implementation of the Parcelable interface is more complex than the implementation of the serializable interface, if the single efficiency is recommended to implement the Parcelable interface method.

Ways to pass Java objects intent in Android

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.