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:
On Fri, Mar 11, 2011 at 9:21 PM, Brill Pappin <brill@pappin.ca> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Dianne Hackborn
Android framework engineer
hackbod@android.com
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment