On Wed, Jan 4, 2012 at 9:30 AM, saex <[email protected]> wrote: > The variable that i need to access staticly is a the own MapActivity > instance variable because i need to pass it to another mapView objects > from other activities
This is not a good idea. Once the user presses BACK, that Activity is no longer valid, yet you will be preventing it from being garbage collected (and, presumably, you will be trying to use it). > So i am holding a MapActivity instance in a static field of the > MapActivity itself because i need to access it by other activities and > use that variable in some MapView objects. I doubt that will work well, for the reasons cited above. > Then, the variable will be referenced on my active activity, but... it > will be deleted or will be alive if the Android O.S. deletes the > nonvisible MapActivity ?? An activity will remain active in your process until: -- you call finish() -- the user presses BACK (which, by default, calls finish()) -- you have an unhandled exception in the activity -- the process is terminated http://commonsware.com/blog/2011/10/03/activities-not-destroyed-to-free-heap-space.html -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy -- 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

