Monday, February 1, 2010

Passing a list of objects between Activities

In Android, you can use Bundle to pass data between activities. There are many functions to pass Integer, String, etc. To pass an object, you will need to implement Parcelable interface and override some functions to serialize/de-serialize the object. Here is an example:

ITEM_LIST is just a constant integer for requestCode parameter. This code will be returned in onActivityResult() when the activity exits. You can set it to any non-zero integer. You may check online for more info on startActivityForResult() method.