westmeadboy wrote:
> But it seems that its important to know that you can't just set that
> at the point you call the new activity. Instead it seems you have to
> set it every time the VM is (re)created?

Yes. This is one of the many reasons to avoid such statics, particularly
for dynamic or mutable data.

> If you start Activity2 from Activity1 and the user hits home in
> Activity2 and the VM gets killed...then when the user returns to the
> app, Activity2 will get recreated, but Activity1 won't, right? 

Not immediately, no.

> If so,
> then Activity1 can't be used to set up the static used by Activity2.

Correct.

> Would be really useful if someone could confirm this.

Hi! Farproc speaks truth! :-)

>>> When starting a new Activity, I want to pass a complex object

Ick.

If this is truly transient state, make the object be Parcelable.

Otherwise, I encourage you to rethink your plan. Perhaps you need to
make those be one single activity rather than two. Or perhaps you need
the data to be mediated by another component (e.g., a service). Or,
perhaps you need the data to be static, but via some singleton object,
where that object is capable of lazy-rebuilding the data when needed
after a VM restart.

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

Android Online Training: 26-30 April 2010: http://onlc.com

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

Reply via email to