Hi I am developing the chat app for android (just private project)
What solution is more optimal?
Thanks for your suggestions.
I'm not familiar with the magic you're talking about ...
But it's not activities job to hold data, their job is to show them.
Solution i propose is that you have a ChatManager
, for instance and it's a singlton. This manager could hold some sort of data structure for all your active chats [ones that were opened since you opened the app], maybe a Map
whose key is a model object that represents the Contact
your chatting with and the value could be a List of Message
s belonging to that chat session.
Activities "save and restore" technique isn't meant to be keep data between activity completely being finished and opened later, it's meant to keep data during a configuration change of some sort or having your activity killed by the OS due to low memory or something ..