tags:

views:

22

answers:

1

Hello. I'm in need to serializing a comprehensive application (game) state to be transmitted over a network or saved to disk and retrieved at a later time.

Bundles, of course, are used to save/restore states in several use cases, so using them would be ideal. However, for some reason, Bundle isn't serializable.

Searching for a solution has only turned up the unacceptable hack of turning the Bundle into a Parcel and then marshalling that, but it is not an acceptable solution because there is no guarantee that it will be possible to unmarshall the data at a later date or on a remote device.

So as it looks now, the only solution appears to be to get the entire set of keys from the Bundle, get each contained Object, do a rather huge switch/case on each Object.Class and manually construct a giant ByteBuffer or similar from all this data, along with size and type information in order to successfully reconstruct the whole thing on the other side.

Not exactly smooth.

Does anyone know of a better way? Perhaps someone has already created a utility function for Bundle that does this?

A: 

Great Question! I wonder if you need to serialize the whole bundle or just information contained? Probably you only need the information which you you can save in just any type (String, List or Array). Take a look at the subclasses of java.io.Serializable, which is humongous.

BennySkogberg