Is it possible to to put an object of type Object into an intent as a Extra? I have a variable of type object and won’t know until it is assigned a value as to what the object datatype is. Maybe something to do with serialization or as a bundle i’m not sure? And then in the next activity how do I then get this value in order to store it in an ArrayList<Object> ?
Is it possible to to put an object of type Object into an intent
Share
Bundleby way ofIntent#putExtradoes not have any function to add anObject. You can only pass in aParcelableor aSerializableobject. Any object you want to pass via anIntentmust implement one of those interfaces. It’s recommended to implementParcelablethere is a brief guide here: Pass by value Parameters using Parcelables.Also this question has more helpful answers: How to send an object from one Android Activity to another using Intents?