Pass object from an activity to another?

by Long » Thu, 15 Oct 2009 20:53:07 GMT


Sponsored Links
 Hi,
  There is an activity which has an object. This activity(say A)
starts another activity(say B).
  Can B use some object in A?


Cheers.
Long

--~--~---------~--~----~------------~-------~--~----~



Pass object from an activity to another?

by niko20 » Thu, 15 Oct 2009 22:04:40 GMT


 Hi,

Why not pull the object out into global scope instead? Just make a new
java file, put a class in there with a static member variable of your
type. Then activity A can set the type (create "new" on it) in the
global class. Now activity B can access it thru the global class.

-niko



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Pass object from an activity to another?

by Long » Thu, 15 Oct 2009 22:54:14 GMT


 I didn't realize your method.
I will try that.

Thanks.






--~--~---------~--~----~------------~-------~--~----~



Pass object from an activity to another?

by Yusuf Saib (T-Mobile USA) » Fri, 16 Oct 2009 02:51:51 GMT


 Before you call startActivity with an Intent, first put extra into
into it with Intent.putExtras:
 http://developer.android.com/reference/android/content/Intent.html #putExtras(android.os.Bundle)


Yusuf Saib
Android
T  Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.




--~--~---------~--~----~------------~-------~--~----~



Pass object from an activity to another?

by Sponge » Fri, 16 Oct 2009 03:47:57 GMT


 i think normaly by small objects to pass between activities ( like a
string or an integer) i would also use the putExtras of the intent.
But if you want to pass an own object of type ClassX i first tried to
use the putExtras(Serializible myObject) and this works if you only
want to display it, but if you want to change it in your data
structure this doesn't work because it seems that there is a copy
created of the object when it is passed in the intent, so if you
change attributes of the object after passing it, there will be no
change in your file structure.
perhaps one solution would be to add an id to every object you create
(like an integer) and pass this integer to get the object in the new
activity or you realy make a static var where you store the object
while passing it, but i dont realy like the static way. i use some
activitys multiple times for diffenent objects to display so i cant
just store everything in a static var because then it would be
overwritten.

On Oct 15, 8:50pm, "Yusuf Saib (T-Mobile USA)" <yusuf.s...@t-




--~--~---------~--~----~------------~-------~--~----~



Pass object from an activity to another?

by Paul Turchenko » Sat, 17 Oct 2009 08:15:16 GMT


 Use Application class.





--~--~---------~--~----~------------~-------~--~----~



Pass object from an activity to another?

by Agus » Tue, 20 Oct 2009 21:01:01 GMT


 serialize your Object to bytes using protobuffer and include the bytes in
the intent's extras.








--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. SlidingDrawer handle

Hi!
Quick question: what is the drawable ID of the handle for the
application's SlidingDrawer used in the home screen?
Thanks in advance!

-- 

2. Native Bluetooth programming

I'd like to create native library for Java (using Android NDK) for
Bluetooth. I have read a sample from
http://blog.bruary.net/2009/07/android-bluetooth-hacking-using-ndk.html
but I cannot get hci_get_route working on my HTC Legend. It returns
ENODEV, Bluetooth is enabled and appropriate permissions are in the
application manifest.

-- 

3. Help! Download aplikasi di android market

4. OOT:WinMo devices yg mulus jalanin dual boot Android

5. newbie ni...gimana cara upgrade magic ke 2.1

6. aidl.exe is missing from tool directory

7. Help: Gak bisa ngetik di magic