So just to clarify: the advantage of using a Singleton object will be that if the app is killed, the Singleton object can just be recreated when it is needed. So you could use a Singleton object in the Application class to assure that it will be initialised when it is needed and the Singleton object is still global?
On Friday, 24 September 2010 07:47:06 UTC+2, TreKing wrote: > > On Thu, Sep 23, 2010 at 8:36 PM, elubin <elubi...@gmail.com > <javascript:>>wrote: > >> That absolutely sounds like what is happening, but WHY would my app be >> killed and restarted? >> > > I'm guessing because it's idle long enough and Android feels like killing > it. If you're leaving your app alone over night, likely your phone is going > to sleep, pausing your app. Left in this state long enough, it's not > surprising that it would be killed eventually. > > >> You are correct, if it gets restarted on the main window then i am not >> refilling my application data. I only fill it on the login window. Do I >> misunderstand how application data is supposed to work? >> > > Perhaps. As Dianne usually advises, you should scrap the Application idea > and use a lazy-loading Singleton object to store your global / app-wide / > static data as necessary. > > >> what's the point of it if the JVM can kill my app at any time and not >> store the application object? >> > > Well, I guess the point is to have the notion of an object that represents > your app as a whole. But it's not the system's job to store and restore > it's state - that's your job. > > On Thu, Sep 23, 2010 at 11:56 PM, Frank Weiss <few...@gmail.com<javascript:> > > wrote: > >> I think the lesson is that an Android application and >> android.app.Application are frequently mistakenly assumed to behave the >> same as an "application" on other operating systems. > > > Yes, this is an important point. OP, you must remember that leaving your > app "open" does not mean it will never close as it does on Windows, for > example. Android will kill it and restart it as need be - it only *appears* > to have remained open since it restarts in the last activity you left it in. > > > ------------------------------------------------------------------------------------------------- > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago > transit tracking app for Android-powered devices > > -- 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