Parceable wtf is this google

Put your problem here if it does not fit any of the other categories.

Parceable wtf is this google

Postby hoffm263 » Fri Aug 24, 2012 8:29 am

Im trying to do something very simple and it seems like either I dont understand the reasons or google hates me.

I have one activity class that should open another activity which represents form data. The form in the second activity should be populated with some defaults that are entered in the first action. I want to pass just one form object from the first activity rather than have to pass all the form values individually - but one of the form items should be a android.location.Location object. This object is causing issues since it is Parceable rather than serializable.


in activity 1 I have:
Intent i = new Intent(this,MarkActivity.class);
MarkForm form = new MarkForm();
//form.setCurLocation(this.myLocation);
form.setLocationName("0000001");
form.setRating("N/A");
form.setAutoRate(false);
i.putExtra("form_data",form);
startActivityForResult(i, 0);


In the second activity I have

getIntent().getSerializableExtra("form_data");

The MarkForm itself is a simple serializable POJO with the following objects:

private static final long serialVersionUID = 1L;
public String locationName = null;
public String rating = null;
public Boolean autoRate = true;
transient private Location myLocation = null;

Of course myLocation will not be passed since it is transient and it causes an exception without the transien key since google in its infinite wisdom made it non serializable.

My options are all bad design choices in my opinion.

1). Pass several objects to the second action and reconstruct the form in the second action (ie pass the non serializable objects using putExtra("myLocation", myParceable);
2). Make my form object a Parseable object. Really .... why should I do all the work of serializing the object when java does it automagically for me.

Either way I need to do extra work to do something that should be fairly simple / straight forward. Im really curious as to why google created this Parseable interface - seems like it is just some hacked up version of serializable?

Maybe there is some best practice or I hope Im just missing something obvious.
hoffm263
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Aug 24, 2012 8:09 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 15 guests