I had this issue before, I had to choose between
1 - Remove unnecessary data from the object I wanted to pass around (in my case it had arrays full of data not needed on the destination Activity).
2 - Implement a singleton to pass around data. Imagine you are going from Activity A to Activity B:
Create PassDataSingleton.class:
public class PassDataSingleton {
private static PassDataSingleton instance;
private ObjectTypeYouWantToPassAround object;
public static PassDataSingleton getInstance() {
return instance;
}
public void setObjectIWantToPassAround(ObjectTypeYouWantToPassAround object){
this.object = object;
}
public ObjectTypeYouWantToPassAround getObjectIWantToPassAround(){
return this.object;
}
}
and on Activity A, before starting Activity B, call
PassDataSingleton.getInstance().setObjectIWantToPassAround(yourObject);
on Activity B, you get the object:
PassDataSingleton.getInstance().getObjectIWantToPassAround();
PS:
- Of course the names and types of my example can (should) be changed
- This same code sample works with lists, just use ArrayList< ObjectTypeYouWantToPassAround> instead