On Fri, May 25, 2012 at 2:10 PM, Orchestrator <[email protected]> wrote: > On the first time my app is running, on the root activity, the user is > required to select a certain options that determines which data would be > downloaded for him from a database. > > Once he had picked that option, the data is downloaded and kept on a > singleton class that should hold that data as long as the application is > running. (Even in the background) > > My problem is that sometimes after the user exits my application for a while > (using the home button), Android apparently kills some of the activities in > my app, and somehow with them, it resets the important singleton class.
No, Android is terminating your entire process: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html > I was looking for a solution, and I found out about > "android:alwaysRetainTaskState" attribute that I can apply on my root > activity. Apparently with it, whenever android decides to kill my app, it > would at least force the user to begin from the first activity where I can > re-download the data, instead of allowing the user to begin with a more > advanced activity causing him to get null exceptions. > > However when I applied it on my application it did not work, and when I > returned to my application I was beginning from an advanced activity, with > an empty singleton instance. Then it is behaving as documented: http://developer.android.com/guide/topics/manifest/activity-element.html#always > Is there something I'm doing wrong? You are not caching your data in a persistent form, such as a file, and using that cache. > Is there any chance maybe there's a > better solution for keeping the singleton alive? No, sorry. The OS, or the user, can get rid of your process whenever they wish. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- 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

