Android: Serializable Intent

I have an object that has (among other things) a list of Intents. I want to pass this object as an extra to an Intent. However, the Intent class is not serializable, it is just "Parcelable".

I assume that Parcelable is the android version of Serializable, but I'd rather not have to write my own serialization code for my class, and Parcelable seems to require that.

Anyone have any solutions to this other than just reimplementing the Intent as a serializable class?

Asked by: Fenton362 | Posted: 24-01-2022

Answer 1

You can put a Parcelable in an Intent extra, and an Intent is already Parcelable. All you need to do is make your object Parcelable and you are set.

Answered by: Fiona242 | Posted: 25-02-2022

Answer 2

Another Route you can take:

make your list of intents transient(not included in a serializable), then pass it as a parcelable array via Intent.putExtra(String key, Parcelable[] value).

The receiving class can then recreate your Object.

Answered by: Maddie784 | Posted: 25-02-2022

Similar questions

android - Does a serializable object always get serialized when put in a bundle?

We were wondering if when using Bundle with serializable or parcelable objects, when does the marshalling actually happen? As soon as you put it in the bundle? Since bundles are mostly used to simply pass around data between two screens (we're not even talking about IPC here!), there doesn't seem to be much point in marshalling an object, since it stays in memory all the time, no? Are we right in assum...

Is using Serializable in Android bad?

I've been reading a lot of posts and articles extolling the speed of Parcelable over Serializable. I've been using both for a while to pass data between Activities through Intents, and have yet to notice any speed difference when switching between the two. The typical amount of data I have to transfer is 5 to 15 nested objects with 2 to 5 fields each. Since I have about 30 classes which must be transferable, implem...

android - What's the best practice to pass data between Activities? Should I favor Parceable over Serializable as Intent Extra?

I'm developing an app which basically navigates through a xml-feed. When I parse the feed or let's say the list, then each (list)item becomes a model. All the models are wrapped up in an array list. Now, when the user clicks on a list item, the underlying model is going to be serialized and sent as IntentExtra to the next Activity (e.g. a deeper sub list).

android - Best method for saving data - preferences, sqlite, serializable or other?

I've been investigating alternative methods for saving my game's data between turns, and wonder if anyone can point me in the right direction. I have approximately 32k of data which must be saved during onPause. I ruled out preferences due to the sheer quantity of data. I spent a few days playing around with SQLite but couldn't get the data to save in less than two seconds (although the time certainly hasn't been...

android - Serializable an arrayList and Save it and to Read it

I am trying to save a arrayList permanently each time when i click on the button the function will add the new arrayList in the Memory so when will read it in another activity i will read all the arrayList that been save and like that i will be able to keep my data even when i switch off the app and i will save all the history of the data been chosen by a click. This Activity is the one i will like to save the da...

android - Add each time an ArrayList to the serializable file

I am not sure that i understand very well the serializable concept,my question is like that: I Have an ArrayList of class that i call History: public class History implements Serializable { private static final long serialVersionUID = 1L; String nameOfMedicaments,DCI,pathologie,nameOfToCountry; String description; int DCIN; public String getNameOfMedicaments() { return nameOfMedicaments; ...

java - JSONObject Not Serializable?

I am trying to serialize an ArrayList of JSONObjects. But I get the error: 05-07 01:04:24.130: WARN/System.err(913): org.json.JSONObject 05-07 01:04:24.130: WARN/System.err(913): at 05-07 01:04:24.130: WARN/System.err(913): at

marshalling - Android: Any shortcut to Serializable from Parcelable without using marshall()?

I'm aware of the performance differences between Parcelable (fast) and Serializable (slow). However, I need to store certain application information persistently, not just within one lifecycle, thus onSaveInstanceState and associated methods utilising Parcelable objects aren't appropriate. So I turned my attention to Serializable. Primarily I have AbstractList type...

bitmap - Android serializable problem

I created a class, which has several member variables, all of which are serializable... except one Bitmap! I tried to extend bitmap and implement serializable, not thinking Bitmap is a final class. I want to save the class (it basically forms the current state of a game) so a player can pick-up and load the game. The way I see it I have two options: 1) Find another way to save the game state. Any help here...

What is the best way to store a non serializable object instance in android?

i have a class that inherits from BroadcastReceiver and is bound to listen for PHONE_STATE events. inside of the onReceive method, i need an object instance that has to be always the exact same (at least between the state ringing and the next occurrence of ide / offhook). that means i need to store the object somewhere. it can not be serialized nor anyhow be stored in a database or in the SharedPreferences. i thoug...

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android