I have an object Address which has values like: name, address, city, state, zip, phone, etc.
I populate the object with a HTTP call. This variable does get populated. Then I try to pass the object to the next activity by doing so:
Intent intent = new Intent(NewAddressActivity.this, BuildingTypeActivity.class); Bundle b = new Bundle(); b.putParcelable("newAddress", (Parcelable)newAddress); // i had to cast 'newAddress' to 'Parcelable' otherwise, it was giving me an error intent.putExtra("newAddress", b); startActivity(intent); And in the next activity (BuildingTypeActivity), I fetch the object like so.
Bundle b = this.getIntent().getExtras(); if (b != null) { Address address = b.getParcelable("newAddress"); } The issue is, that it always crashes when I it gets to the 'putParcelable' line. It might have something to do with the cast to to Parcelable. So, I am assuming that this is not the right way to pass objects?
Any tips on how to pass objects properly would be greatly appreciated.