9
I'm pretty new to Serializable and Parcelable. I'm having a hard time passing an instance of this object from an application to a remote service:
public class Event implements Parcelable, Cloneable {
/** Defines under what Bundle's key architecture events are stored */
public static final String BUNDLE_KEY = "ZKEvent";
/** Defines which messages are architecture's events */
public static final int MSG_WHAT = 0xDEFECABE;
/** Defines a key to store map under a Bundle to put into a Parcel (oh yeah!) */
private static final String MAP_KEY = "MAP";
/** Indicates this event ID. This ID should be the same in the event answer if any */
private int idEvent = 0;
/** Indicates this event priority */
private int priority = EventPriority.EVENT_PRIORITY_LOW;
/** ID for this event's sender */
private int idSource = 0;
/** ID for this event's destination */
private int idDestination = 0;
/** Action to be performed */
private int action = EventAction.DEFAULT;
public static final Parcelable.Creator<Event> CREATOR =
new Parcelable.Creator<Event>() {
public Event createFromParcel(Parcel in) {
return new Event(in);
}
public Event[] newArray(int size) {
return new Event[size];
}
};
/**
* Event's data
* Represented as
* key -> parameter;
* value -> data
*/
private Map<String, Object> data = new HashMap<String, Object>();
/** Default constructor */
public Event() {};
/** Contructor with ID of the event */
public Event(int id) {
idEvent = id;
}
/** Constructor for Parcelable */
public Event(Parcel in) {
readFromParcel(in);
}
/** Gets event's priority */
public int getPriority() {
return priority;
}
/** Sets this event's priority */
public void setPriority(int priority)