title: Android strict mode detects multiple activity instance violation, but I have no idea why
body: <p>Code is probably too complex to post here in full, but here is the basic schema: I have two <code>Activity</code> subclasses, each of which hosts a <code>ListView</code>.  Each <code>ListView</code> has an adapter of a custom class, which generates <code>View</code> instances also of a custom class.  These lists are showing data items that are generated asynchronously in another thread; as it needs to know where to send updates to, the data objects it manipulates have <code>WeakReference&lt;&gt;</code> objects that are set to hold references to the adapters displaying their contents when they are initialised.  When an object in the list of the first activity is selected, I start the second activity with an intent that instructs it to look up the item and display its contents.  I then use the 'back' button to close the second activity and return to the first. For some reason when I run this with <code>StrictMode</code> checking enabled, it always crashes after a few iterations of switching between the two activities, complaining that there are too many instances of one of my <code>Activity</code> classes.</p>
  
  <p>I have arranged for a heap dump to be written just prior to the crash (see <a href="https://stackoverflow.com/questions/15292383/android-strictmode-and-heap-dumps">Android StrictMode and heap dumps</a>).  These heap dumps always show that there is 1 instance of each of my two activities on the heap at the time of termination.   First of all, is this not to be expected when I have recently switched between the two, and if that is so, why is <code>StrictMode</code> complaining about this?  If it isn't expected, how can I arrange to avoid this?  Examining the heap dump, both objects are referenced from the main thread stack, over which I don't seem to have any useful degree of control.  Each also has a reference from <code>android.app.ActivityThread$ActivityClientRecord</code>, which I also do not seem to be able to control.</p>
  
  <p>So, basically, any ideas how I avoid this situation?  Does this actually represent an activity leak, or is StrictMode just being overly sensitive?</p>