tags:

views:

440

answers:

1

I have an object that has (among other things) a list of Intents. I want to pass this object as an extra to an Intent. However, the Intent class is not serializable, it is just "Parcelable".

I assume that Parcelable is the android version of Serializable, but I'd rather not have to write my own serialization code for my class, and Parcelable seems to require that.

Anyone have any solutions to this other than just reimplementing the Intent as a serializable class?

+1  A: 

You can put a Parcelable in an Intent extra, and an Intent is already Parcelable. All you need to do is make your object Parcelable and you are set.

CommonsWare
Is there an easy way to make your intent Parcelable? Serializable is nice because you just have to throw the interface on, it looks like you have to manually serialize your object in parcelable..
Mayra
`Intents` are already `Parcelable`.
CommonsWare
Yes, I understand that Intents are, but my object is not, and it contains a number of somewhat complex objects. Hand-creating serialization code seems error prone.
Mayra
Since you cannot make an `Intent` implement `Serializable` without firmware modifications, your choices are either to implement `Parcelable` on your class or not pass instances of it via extras.
CommonsWare