What should I pay attention to when uploading objects to an activity in android?

Source: Internet
Author: User

What should I pay attention to when uploading objects to an activity in android?

I implemented the Parcelable interface through serializable, because it was relatively lazy and I didn't want to implement the Parcelable interface.

1. Modify the Class. Because Serializable is passed, inherit implements Serializable after the class.

2. Pass the value

Intent. putExtra (sid, scart );

You can use putExtra directly.

3. Receive Value

Scart = (GoodsList_Details) intent. getSerializableExtra (sid );

In this way, we can basically solve the needs of more than 80% of our friends.

The above method is indeed feasible, but the class extension adds a field, so this transfer is not easy.

Error:

Java. lang. RuntimeException: Parcelable encountered IOException writing serializable object

Check all the classes on the Internet, including the referenced classes. serializable serialization is required.

View my code

Private List Items;

GoodsSpec has no serializable, so I don't hesitate to add this. Okay, everything is OK. record it.

 

 

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.