Hi Raja,

I think the following thread provides good info (although it's become
a bit long): 
http://groups.google.com/group/android-developers/browse_thread/thread/9632cb52888ef6db/9287a1a6a24ea577

Assuming you want to pass Objects between Activities in the *same*
application (i.e. same process), I believe that passing the Object
reference is better than Parceling it using the Intent Extras
mechanism (passing a pointer is obviously more efficient than
parceling/unparceling an object).
If the objects you are passing are relatively lightweight and few in
numbers - the performance difference is probably negligible.
If you want 2 activities to manipulate the *same* object and not 2
different copies of the same object - then you have to pass an object
reference between activities.

I faced this problem pretty early in my development effort, and came
up with the following mechanism:

I created a class called ReferencePasser that wraps a HashMap of
Objects, with Long keys. I have an instance of ReferencePasser
available to all Activities (as a public static field somewhere, or
through the Application object).

When an activity wants to pass an object to another activity, it adds
the object to ReferencePasser and gets a long key as a result. It then
passes this object key to the activity it is starting as an extra,
using some agreed-upon String key. When the called activity is
created, it retrieves the object key from its intent extras, and gets
the object reference from reference passer. It can then remove the
object from ReferencePasser to keep its Map small.

This approach has been working great for me so far, although obviously
it is limited to a single application process.
I'll attach sample code in the next thread.

Hope this helps,

Amos
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to