What's the best approach to parcel/unparcel a HashMap of custom objects?
===

I have an `Event` class that defines a private `HashMap` like this:

    private Map<String, Object> data = new HashMap<String, Object>();

The `Event` class is a wrapped for any kind of "event". This `HashMap` can contain any object instance which is referenced by a key. The class receiving an `Event` instance knows what class is related to each key, so it can safely cast the `Object` to its corresponding subclass.

The problem arises when I try to pass an `Event` instance between 2 processes. `Event` implements `Parcelable` so it can be sent through a `Message`:

    Bundle bundle = new Bundle();
    bundle.putParcelable(Event.BUNDLE_KEY, event);
    			
    // Make the message with the bundle
    Message message = new Message();
    message.setData(bundle);

When unmarshalling:

	public void readFromParcel(Parcel in) {
		
		idEvent = in.readInt();
		priority = in.readInt();
		idSource = in.readInt();
		idDestination = in.readInt();
		action = in.readInt();
		
		Bundle mapBundle = in.readBundle();
		
		if (mapBundle.getSerializable(MAP_KEY) instanceof HashMap) {
			data = (Map<String, Object>) mapBundle.getSerializable(MAP_KEY);
		} else {
			Log.e(TAG, "Parcel reading error: not a HashMap");
		}
	}

The problem is this won't work since I need to specify to `mapBundle` which `ClassLoader` to use, e.g. `mapBundle.setClassLoader(Entity.class.getClassLoader());`. **But** I don't know what `Object` subclasses the `HashMap` will have... 

This is what I thought:

 - Write a `ClassLoader` that loads any of these classes. The problem is that I cannot get a way to obtain the `byte[]` representing the object since it's inside the `HashMap`. And I cannot use `mapBundle.getSerializable()` to get it because it precisely throws `ClassNotFound` exception.

 - Pass some extra information so I can know what classes are on the `HashMap`. Besides this looking as redundant information, still no go because if I set one classloader on the Bundle, it will still throw a `ClassNotFound` exception on the other classes...

I would really appreciate some help on this issue. Thanks in advance!