Let's suppose I want to write an instant messenger client.
I guess there will be at least 2 activities:
UserManagerActivity - enables to manage accounts and logging in.
MainActivity - displaying contacts list etc.
But if I do it this way, there'll be some objects that should be accessible for both of them:
ConnectionManager - will be used for logging in, sending/receiving messages etc.
UserManager - holding information about users.
MusicPlayer - playing sounds.
So, what is the most elegant way to give both activities access to these objects?
I've heard about 4 possibilities:
- Using singleton pattern.
- Passing objects between activities using Bundle.
- Extending Application class.
- Using Service class (seems complicated to me).
Which option do you think is the best one?
Aren't globally accessible classes a sign of a bad project?
How can I learn to design elegant and efficient applications "skeletons"?
Thanks in advance!