android--What are the methods for passing some binary data through intent

Source: Internet
Author: User

1. Methods

(1) serialization is implemented using the serializable interface. Use Bundle.putserializable (Key, object); Here the Objec object needs to implement the serializable interface.

(2) Realize parcelable interface serialization. Use Bundle.putparcelable (Key, Object), where object objects need to implement the Parcelable interface.

2, the difference between the two:

(1) When using memory, parcelable analogy serializable high performance, it is recommended to use the Parcelable class.

(2) serializable generates a large number of temporary variables at the time of serialization.

(3) Parcelable can not be used in the case of storing data on disk, because Parcelable does not guarantee the continuity of the data in the event of external change. Although serializable efficiency is low and is not advocated, it is recommended to use serializable in this case.

3. Realize:

(1) Serializable implementation, only need to inherit implements serializable can. This simply marks the object and the system automatically serializes it.

(2) Parcelable implementation, you need to add a static member variable in the class creator (must be public, otherwise error), this variable needs to inherit Parcelable.creator interface.

Transferred from: http://blog.csdn.net/wulongtiantang/article/details/7937094

android--What are the methods for passing some binary data through intent

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.