Singletons vs. Application Context in Android?
Posted
by
mschonaker
on Stack Overflow
See other posts from Stack Overflow
or by mschonaker
Published on 2010-09-30T00:35:37Z
Indexed on
2012/03/23
17:29 UTC
Read the original article
Hit count: 204
Recalling this post enumerating several problems of using singletons and having seen several examples of Android applications using singleton pattern, I wonder if it's a good idea to use Singletons instead of single instances shared through global application state (subclassing android.os.Application and obtaining it through context.getApplication()).
What advantages/drawbacks would have both mechanisms?
To be honest, I expect the same answer in this post http://stackoverflow.com/questions/2709071/singleton-pattern-with-web-application-not-a-good-idea but applied to Android. Am I correct? What's different in DalvikVM otherwise?
EDIT: I would like to have opinions on several aspects involved:
- Synchronization
- Reusability
- Testing
Thanks in advance.
© Stack Overflow or respective owner