I really think everyone should stop using the Android Framework, since it has more than a handful of singletons.
http://developer.android.com/develop/index.html#q=singleton This is despite research that conclusively proves singletons causing baldness in males and infertility in women. Oh the dangers of working with Android. </irony> -- K 2013/3/15 user123 <ivanschu...@gmail.com>: > What is the problem with singleton? > > It works very well. I use it to hold global state, for example, > translations. They are fetched at the start of the app, and updated each > screen launch (if necessary). This holds the translations in memory and I > can get them from any activity using simple methods. I can control > everything there - reinitialize if destroyed, etc. > > There's also a very popular image loading library, which works very well for > me, which also uses the singleton pattern. It initializes in application's > onCreate() and after that everytime you load an image, just use ~1 line of > code. > > Which better approach would you suggest for these use cases, and why? > > > Am Dienstag, 26. Februar 2013 06:19:24 UTC+1 schrieb William Ferguson: >> >> >>>> >>>> You should access it with a getInstance method which will initialize it >>>> if it is null. >>> >>> You should initialize the variable in the class initialization and >>> declare it 'final'. >>> >>> There are times when you cannot do this, in which case probably Singleton >>> is the wrong choice. >>> >>> For the rest of the times, Singleton probably is the wrong choice. >> >> >> >> :-) +1 to that > > -- > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to android-developers+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.