Oh good lord, there is nothing intrinsically evil about globals or singletons. Just don't abuse them.
For example, say I want to do a query on the package manager about a set of applications that are available. If I stick this as local data inside of a particular activity, then every time the user presses back and returns to the activity the state needs to be reloaded, and if I want to share that state with another activity I need to figure out some way to get the object over to the other activity without using an evil global. Just use a singleton and a global. It's the appropriate tool for this. Like the current code here in Manage Applications, which works 10x better in gingerbread because it was refactored to have a cleanly controlled singleton that tracks everything that needs to be known about the installed applications across all parts of the UI: http://android.git.kernel.org/?p=platform/packages/apps/Settings.git;a=blob;f=src/com/android/settings/applications/ApplicationsState.java;h=6e9f2a2d296ac349e6acde81312485adae5dd351;hb=HEAD#l324 On Fri, Mar 11, 2011 at 9:21 PM, Brill Pappin <[email protected]> wrote: > Singleton is also one to be avoided however... just like global vars :) > However, as we're working on a (sort of) limited device, Singletons are a > way of life. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

