Android - Put Object through Intent by Parcelable and Serializable example

Android developers often face a predicament while passing object references to activities of whether to go with the Java Serialization method or opt for Android Parcelable. This post is my attempt to compare the two techniques and cite an example to show how to implement them.



1. Create an customize object implements Serializable (Animal.java) :
2. Create another customize object implements Parcelable (Plant.java):
3. Create an activity which run when app start (put object through intent here):
- Simple layout like this (activity_root):
- Java code (RootActivity):
4. Create a destination activity to receiving object through intent (DestinationActivity):

5. Running app, we will have these screens:

pic name pic name pic name
(Sorry for ads at download link)

Share


Previous post
« Prev Post
Next post
Next Post »