I'm not sure if what I'm asking is correct, so please forgive my ignorance.
I need to use an object initialised in the main activity in another one.
I serialized the object class with implements Serializable
and sent it to the new activity putting into an extra, retrieving it later with intent.getSerializableExtra
.
The other way would be access directly the previously public declared object from the activity using the following:
MainActivity mainActivity = (MainActivity) this.getParent();
Object object = mainActivity.object;
Is any of this correct?
If yes, which one?
If both which is better?