Which will work but is kind of fragile.

End-user starts a new Task with first Activity A. The end-user then
clicks a button on Activity A's layout causing the parameters to be
pass to be stored in the static object and Activity A now calls (via
intent) Activity B.

Activity B accesses the static(s) and show's it's layout, all is good.

User presses [home] and looks at google maps; this causes the process
hosting Activities A and B to be killed because of low memory.

User long presses [home] and selects the task that started Activity
A.  Android has to create a new process for the task and because
Activity B was on top of the task stack Activity B is started and
tries to access the static(s) which are now NULL.

Bad things happen ;)

--
RichardC

On Oct 18, 6:19 pm, niko20 <[email protected]> wrote:
> Hi,
>
> You don't need to pass it using intents, just use a static class with
> static public variables, and you can make one of those variables a
> type of the object you are trying to pass. Then just assign that
> variable to your instance. Now any activity can get to it by using the
> global accessor (so if you have a static class named "myclass", and
> the variable is "myobject var1", you can get to it from anywhere using
> myclass.var1 cause it's all static and therefore global in scope)
>
> This would be much easier, cleaner, and faster.
>
> -niko
>
> On Oct 18, 8:49 am, "[email protected]" <[email protected]> wrote:
>
> > I am trying to pass a user defined object to another activity
>
> > Bundle bundle = new Bundle();
> > bund.putSerializable("myData", myData);
> > intent.putExtra("bundle", bundle);
>
> > where myData class implements Serializable interface.
>
> > I am getting following error:
>
> > java.lang.RuntimeException: Parcelable encountered IOException writing
> > serializable object
>
> > Could anyone please let me know how to pass complex objects between
> > activities?
>
>
--~--~---------~--~----~------------~-------~--~----~
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