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

Reply via email to