Which is indeed a big problem and a cause of many crashes or force-closes. If something needs to run in the background (as a Thread or a Task/AsyncTask/Future) and it will possibly survive the destruction of an activity:
- Avoid making your (anonymous or inner) Thread/AsyncTask/etc sub-class a non-static class. *Make it a static class*, so that it doesn't hold an implicit 'this$0' pointer to your enclosing activity. - *Tie it to a non-configuration instance*(getLastNonConfigurationInstance/onRetainNonConfigurationInstance) or to a Fragment that is retained (setRetainInstance(true)). Stop or just ignore the thread (depending or your Thread/Task/etc) when you activity is really dying (isFinishing() == true) or when the Fragment is destroyed entirely. -- 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

