Home >Java >javaTutorial >How to Pass a Serializable List of Objects via Intent in Android?
Passing Objects with Serializable
In this query, the user is encountering difficulties in transferring a serializable class via an intent. Despite implementing Serializable, the operation remains unsuccessful.
The class involved, Thumbnail, contains attributes and methods for managing labels and bitmaps. The user attempted to send a list of these Thumbnail objects via intent, but without success.
To resolve this issue, it is not necessary to use Parcelable. Instead, the user can pass the serializable list using a Bundle.Serializable within the intent.
Bundle bundle = new Bundle(); bundle.putSerializable("value", all_thumbs); intent.putExtras(bundle);
On the receiving end, within the SomeClass Activity:
Intent intent = this.getIntent(); Bundle bundle = intent.getExtras(); List<Thumbnail> thumbs = (List<Thumbnail>) bundle.getSerializable("value");
This approach enables successful data transfer of the Thumbnail object list via intent using Serializable.
The above is the detailed content of How to Pass a Serializable List of Objects via Intent in Android?. For more information, please follow other related articles on the PHP Chinese website!