I'm making an Android app which is sending 2 type of objects which implements the parcelable interface (lets call them objectA and objectB) over network as byte arrays. But on the receiving end I need to know which type of object arrived in the parcel. The parcel.readValue() method only returns Object, so on the receiving end I don't know which object should I recreate objectA or objectB. How can this be done? Do Parcels have some kind of metadata in them which describes the type of the original object?
Edit: the language is Java
Edit: Added example code
ObjectA objA = new ObjectA("uid", "description");
byte[] bytes = ParcelUtil.toBytes(objA); //this simulates the sending
Object rebuilt = ParcelUtil.rebuildFromBytes(bytes); //here I don't know what am I rebuilding, objectA or objectB
if(rebuilt instanceof Parcel){
Parcel p = (Parcel) rebuilt;
ObjectB oB = (ObjectB) p.readValue(ObjectB.class.getClassLoader());
if(oB.getUid() == null){
ObjectA oA = (ObjectA) p.readValue(ObjectA.class.getClassLoader()); //this will also be full of null values
}
}