what is difference between Parcelable and Serialization used in android
whether should i used parcelable or serialization technique for sending data from one activity to other.
If you are sending a non-primitive type data/Object to another activity through the intent
you have to either Serialize
or implement Parcelable
for that object. The preferred technique is Parcelable
since it doesn't impact the performance.
is it compulsory to use one of them for sending data from one to other. / when should i use them.
It is only compulsory/used for sending non-primitive type data objects.
and the exact difference between them and performance of both of them in java aspects.
Serialization does impact the performance. For more details check this link Android Parcelable and Serializable
Difference between Serializable, Parcelable in Android
Parcelable and Serialization are used for marshaling and unmarshaling Java objects.
More details : http://www.developerphil.com/parcelable-vs-serializable/
What are Serialization and Parcelable
Parcelable and Serialization are used for marshaling and unmarshaling
Java objects.
Parcelable is well documented in the Android SDK; serialization on the other hand is available in Java. It is for this very reason that Android developers prefer Parcelable over the Serialization technique.
· In Parcelable, developers write custom code for marshaling and unmarshaling so it creates less garbage objects in comparison to Serialization. The performance of Parcelable over Serialization dramatically improves (around two times faster), because of this custom implementation.
· Serialization is a marker interface, which implies the user cannot marshal the data according to their requirements. In Serialization, a marshaling operation is performed on a Java Virtual Machine (JVM) using the Java reflection API. This helps identify the Java objects member and behavior, but also ends up creating a lot of garbage objects.
Due to this, the Serialization process is slow in comparison to Parcelable.
Check below link: very good explanation and example.
http://www.3pillarglobal.com/insights/parcelable-vs-java-serialization-in-android-app-development
Related Topics
Vertical (Rotated) Label in Android
How to Display Count of Notifications in App Launcher Icon
Scheduling Recurring Task in Android
How to Use the Animation Framework Inside the Canvas
How to Handle Screen Orientation Change When Progress Dialog and Background Thread Active
Android Intent Filter: Associate App With File Extension
What Is the Android Uithread (Ui Thread)
Key Hash For Android-Facebook App
How to Close Android Application
What Does @Hide Mean in the Android Source Code
Get Root View from Current Activity
Download Binary File from Okhttp
Removing an Activity from the History Stack
Can't Find Theme.Appcompat.Light For New Android Actionbar Support
Capture Image from Camera and Display in Activity