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. One line causing lots of garbage collection. String.format with float. Help?

When you say that it hasn't improved your garbage collection problem,
do you mean that it still GCs 13000 objects every 2 seconds?









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

2. Question about android graphics.

Hi All,

  I am tring to analyse the android graphics. After reading the source
in android, I still have no idea how it works. Here I list a few
questions. Any reply will be welcome.

1.  what is the relationship between ViewRoot and View class. As my
understanding, in each window, there is only one ViewRoot, even though
there are mutil View or ViewGroup shows in that window. The showing
route is started by WindowManagerService as below:
ViewRoot::handleAppVisibility()-->ViewRoot::handleAppVisibility()--
In view::draw, it will draw its data to its canvas and dispatch draw
calling to its children's view.
Is all view ,its children's view and their viewRoot share the same
canvas for draw?


2. What is the relationship within View, canvas and Surface.  To my
thinking, every view will be attached a canvas and surface. And a
canvas hold the bitmap for view, will the actual view drawn data will
be in canvas' bitmap. After View draw its data to canvas, ViewRoot
will call surface.unlockCanvasAndPost(canvas) to schedule
surfaceFlinger::composeSurfaces() which do the actually display to
display panel.

Where is the drawn data in canvas transfer to surface front buffer or
backbuffer? I cannot find the code to do that.

Do different views within the same ViewRoot share the same surface?

Thanks


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

3. No targets to build using Android 1.5 SDK...

4. How the use same instances when launching application twice

5. LTTng on Android

6. TDD with Android 1.5

7. Developing absolute layout - no drag drop click drag in eclipse ??