On Sun, Dec 5, 2010 at 2:42 PM, Neilz <neilhorn...@gmail.com> wrote:

> 1) This is useful as you can put a lot of common methods and vars in
> there,,,
>

As Mark said you can't really do this if you use any of the derived Activity
classes (List, Tab, and especially Map). For this kind of "common activity
stuff" I created a proxy of sorts - a class that takes an instance of an
Activity and implements functions that are common for all. Then each
Activity just creates an instance of this proxy with itself and uses it to
do the common logic stuff. It's a little more verbose, but works to
centralize the common code given the restrictive inheritance hierarchy.

2) I created a load of static objects which, when launching my intents, I
> populate the static objects so that when the next activity is launched
> they're there ready. No bundles, no parcelables, simple.
>

What happens when:
You start Activity A which initializes a bunch of static objects.
>From A you launch Activity B which is depending on these static being
initialized by A.
You press Home and do other things for an hour or so, eventually your app
gets wiped from memory, including the statics.
You come back to your Activity, which will start at B since that was the
last thing the user saw.
A will NOT be called to initialize your statics and B will be using default
or non-initialized static data.

I would be very careful with using static data to store instance state
across Activities.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

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