Parcelable where/when is describeContents() used?

There is a constant defined in Parcelable called CONTENTS_FILE_DESCRIPTOR which is meant to be used in describeContents() to create bitmask return value. Description for CONTENTS_FILE_DESCRIPTOR in the API ref is: Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled. Which really means: If … Read more

How to send objects through bundle

You can also use Gson to convert an object to a JSONObject and pass it on bundle. For me was the most elegant way I found to do this. I haven’t tested how it affects performance. In Initial Activity Intent activity = new Intent(MyActivity.this,NextActivity.class); activity.putExtra(“myObject”, new Gson().toJson(myobject)); startActivity(activity); In Next Activity String jsonMyObject; Bundle extras … Read more

how to properly implement Parcelable with an ArrayList?

You almost got it ! You just need to do : public void writeToParcel(Parcel out, int flags) { out.writeString(_mac); out.writeString(_pan); out.writeInt(_band); out.writeSerializable(_lqis); out.writeTypedList(_devices); } private ZigBeeNetwork(Parcel in) { _mac = in.readString(); _pan = in.readString(); _band = in.readInt(); _lqis = (ArrayList<Integer>) in.readSerializable(); in.readTypedList(_devices, ZigBeeDev.CREATOR); } That’s all! For your list of Integer, you can also do … Read more

Pass 2D array to another Activity

You can use putSerializable. Arrays are serializable. To store: bundle.putSerializable(“list”, selected_list); // Here bundle is Bundle object. To access: String[][] passedString_list = (String[][]) bundle.getSerializable(“list”); Example Intent mIntent = new Intent(this, Example.class); Bundle mBundle = new Bundle(); mBundle.putSerializable(“list”, selected_list); mIntent.putExtras(mBundle);