I'm creating an app where I need to pass relatively complex classes between several Activity
s and Service
s. Lets say something like this:
public class A implements Serializable{
int myInt;
String myString;
B myB;
}
public class B implements Serializable{
ArrayList<String> myStrings;
}
Now this can be done by Intent.putExtra(String, Serializable)
, but I could also create a singleton class holding the A
instance. Using a singleton provides easy access to my instance of A
, but it seems a bit 'hacky' to me.
What are the up and down sides of using both methods? Are there any strict reasons why I shouldn't use one of the methods?