Well you would have this problem even if you passed the variable, you
have to regenerate the data. Regenerating after a close is a
completely different issue than what he is talking about.

Using a static class would work just fine to share data. I use it in
my apps and it works great.


-niko

On Oct 18, 2:45 pm, RichardC <[email protected]> wrote:
> All of what you suggest is possible.
>
> What I was trying to emphasise is that as Android can kill any process
> that is not the active task, any static variables (state information)
> will be destroyed and need to be re-created when the new process is
> started.
>
> One could for instance save the static information in the call back
> onSaveInstanceState and restore it in onCreate or
> onRestoreInstanceState.
>
> --
> RichardC
>
> On Oct 18, 8:12 pm, Dan Sherman <[email protected]> wrote:
>
> > I'm not aware of any such feature, but is it possible to force android to
> > disregard the stack, and open Activity A regardless? (could solve the
> > problem, especially if B depends strongly on A).  Could also probably check
> > for a null variable and send an intent back to A anyway :)
>
> > - Dan
>
> > On Sun, Oct 18, 2009 at 2:53 PM, RichardC 
> > <[email protected]>wrote:
>
> > > 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