Skip to content

Parcel & Parcelable

davnil74 edited this page May 8, 2012 · 1 revision

Passing data between activities

Passing data between activities is quite easy. You would normally do that using the Bundle packed into an intent. But sometimes you need to pass complex objects from one activity to another. To pass such objects directly through the Bundle, your class would need to implement the Parcelable interface.

- Why don´t you just pass a Serializable as a parameter?

Well, Serializable also helps, but it's too slow as compared to Parcelable. In Android parlance, I assume that your objects that you would need to pass between Activities would not be super complex. Implementation-wise, Serializable seems to be a lot simpler, but if you consider the performace, Parcelable wins here.

http://techdroid.kbeanie.com/2010/06/parcelable-how-to-do-that-in-android.html

http://developer.android.com/reference/android/os/Parcel.html

http://developer.android.com/reference/android/os/Parcelable.html

Clone this wiki locally