[android-developers] Re: How to pass objects around activities using "A HashMap of WeakReferences to Objects"?
Anil didn't say "WeakHashMap", he said "HashMap of WeakReferences".
I think the idea is that if you've just placed something in a (shared)
HashMap with the value being a WeakReference to the object of
interest, then immediately launch an activity to grab that value by
id, the value you placed in the map will almost 100% be guaranteed be
available by the time the activity's onCreate is called, but not
permanently occupying space on the heap. Sure, it's not 100% safe to
assume it exists, but a likely bet if the gc uses any kind of LRU
mechanism to clean up a weakly referenced object. And, if your data
source allows, you can always fail back to a second lookup on the key
if the referenced object value doesn't exist at onCreate.
Or you can just Bundle/Parcel your object value and stash it in the
intent if you don't mind the time and space overhead of that.
Doug
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home