On Sun, Dec 5, 2010 at 3:42 PM, Neilz <neilhorn...@gmail.com> wrote:
> Now maybe this is obvious, but I must say I haven't seen this in any
> other examples. I'm wondering if there's something 'wrong' with  this,
> any reason why this shouldn't be done?

1. Watch for memory leaks. Do not put things in static contexts that
might reference another Activity, for example (e.g., a widget).

2. Since Java does not support multiple inheritance, the base class
may interfere with uses of other activity classes (e.g.,
PreferenceActivity, MapActivity), or require code duplication.

Rather than having a "load of static objects", you could have just one
singleton that itself holds onto a "load" of other data. That will
make it easier for you to migrate to another approach (e.g., Service,
custom Application) if you so choose to later. It also consolidates
your initialization, makes it a bit easier to give the static data
more smarts about its static-ness (e.g., LRU algorithms to minimize
memory creep), etc.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
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

Reply via email to