The listener I'm talking about is custom and only accepts a single listener at a time which is held as a member variable of my custom listener class, it's not an Android Listener. I did have a LocationListener in my code but even after commenting it out I still see the same behavior.
I've chosen singletonInstance in hopes of avoiding the problem I have now. It just seems to me from a memory perspective it could be better to have less instances of the application in memory, but based on your response I will remove it. I better understand the innerworkings of Android, and I thank you, however the problem remains. Thanks! On Mar 13, 1:37 pm, Mark Murphy <[email protected]> wrote: > AuxOne wrote: > > Shouldn't it suffice to just re-register the listener onCreate()? > > If you are talking about registering some listener with Android > (LocationListener, etc.), then no. Please unregister your listeners. > > > Btw, the Activity is a singleton > > ( android:launchMode="singleInstance") so there's only one instance. > > singleInstance != singleton. > > Let's walk through this, starting with a freshly-rebooted phone. At this > point, there are zero instances of your activity. > > 1. User taps on your icon in the Launcher. Android starts up an instance > of your Activity. At this point, there is one instance of your activity > in the system. > > 2. You register a LocationListener. At this point, there is one instance > of your activity in the system. > > 3. User presses BACK, and you fail to unregister the LocationListener. > At this point, from the standpoint of singleInstance, there are zero > instances of your activity in the system. However, from a garbage > collection standpoint, there is one instance of your activity in RAM, > since Android holds onto your LocationListener, which holds onto your > activity. > > 4. User taps on your icon in the Launcher. Android thinks there are zero > instances of your activity in the system (from a singleInstance > perspective), and so starts up an instance of your Activity. At this > point, there are two instances of your Activity in RAM -- the old one > and the new one. > > It is unclear to me what you think you need singleInstance for -- most > single-activity applications do not need singleInstance. So, I would get > rid of that, plus clean up your listeners. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://twitter.com/commonsguy > > Android 2.0 Programming Books:http://commonsware.com/books -- 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

