Yes this is very dangerous.  There is a good chance that if the user hits
home, and later returns to your app, the process will have been killed and
all static data in it lost.  This is very unlikely to happen when just
switching from one app to another (the process in that case stays in the
foreground bucket), but still I am not going to make any guarantees.

On Fri, Mar 13, 2009 at 8:06 AM, Tushar <tusharpatu...@gmail.com> wrote:

>
> Yes my Activities are all in the same application. I'm not sure about
> "Task".
>
> Although I'm not killing my one activity (say activityOne )when
> launching another activity ( say activityTwo) but are there any
> chances that Android might simply kill my activityOne and I may loose
> the data which I'm expecting in  activityTwo by storing it as static ?
>
>
>
> On Mar 13, 4:00 pm, Edward  Falk <ed.f...@gmail.com> wrote:
> > Are the activities all in the same application?  Same task?  It seems
> > to me that you could just store the data in a static variable
> > accessible by all of the activities.  Am I missing something?
> >
> > public class MainActivity extends Activity {
> >   ...
> >   static MyDataStructure dataStruct = null;
> >   ...
> >   public void onCreate(Bundle state) {
> >     ...
> >     dataStruct = ReadData();
> >   }
> >
> > }
> >
> > ...
> >
> > public class AnotherActivity extends Activity {
> >   ...
> >   void SomeMethod() {
> >     DoSomethingWithData(MainActivity.dataStruct);
> >   }
> >
> > }
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to