Yes, it's quite possible to create the same situation with your own
listeners as with listeners passed to Android.

All that's required is that 1) you hang onto the listener somewhere
that isn't itself GC'd, and 2) it points to your Activity (which may
be implicit, for a non-static nested class).

You COULD analyze the situation closely. Or, you could simply arrange
to unregister your own listeners. Personally, I would take AT LEAST
the second option, and probably the first as well if I were designing
a library.

You don't ideally want to actually make your app's process disappear
on the Back button in most cases. It slows down the interface. You
want to leave memory management to the OS.

On Mar 13, 6:31 pm, AuxOne <tyler.thack...@gmail.com> wrote:
> This whole "static context" thing has me worried. Now I'm wondering
> what loose end is left that is causing this behavior. I'm not
> registering any Android listeners but perhaps my own listeners are
> holding it up. It seems to me that whatever state the application is
> in when the phone first starts, is where I'd like mine to be when the
> back button is pressed... because it works great on the first launch.
>
> What is the difference between the BACK button being pressed versus
> Android killing your app from low memory? I'm asking because one
> solution I've found is to override the behavior of the BACK button so
> it acts like the HOME button, which makes sense in the context of my
> application. The only problem is if the app is killed by the OS (and
> if that behavior is the same as the BACK button) then my app will have
> the same problems when it's relaunched. Otherwise, that's the solution
> I'm going with.
>
> Thanks
>
> On Mar 13, 2:13 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
>
>
> > AuxOne wrote:
> > > 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.
>
> > Android handles cleaning up destroyed activities for you automatically,
> > so long as you're not holding onto them from a static context, which is
> > where an unregistered LocationListener will get you in trouble.
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> > Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to