Hopefully I can clearly confirm what is actually happening.  There are only
two ways your entire activity instance can go away:

1. At some point the activity lifecycle completing and onDestroy() being
called.
2. The process being killed.

Thus you will not have a resource leak if you release the resources in
onStop() or onDestroy().  Generally you pair onCreate() with onDestroy(),
onStart() with onStop(), and onResume() with onPause().  You can however do
variations if you are careful such as allocating in onStart() (if not
already allocated) and releasing in onDestroy().

Also it may be worth mentioning -- there was a significant change to the
activity lifecycle in 3.0 where onStop() is now guaranteed to be killed
(prior to killing a process) like onPause() has always been.  In fact if you
are targeting API 11 or greater, you will find onSaveInstanceState() now
being called between onPause() and onStop().

On Wed, Apr 27, 2011 at 6:14 PM, Mark Murphy <mmur...@commonsware.com>wrote:

> On Wed, Apr 27, 2011 at 5:55 PM, Eric <e...@alum.mit.edu> wrote:
> > Android is allowed to 'clean up'
> > your activity right after onPause(), without killing the app, if it
> > wants to reclaim memory.
>
> By finishing the activity, thereby triggering the
> onPause()/onStop()/onDestroy() triad. If the activity is paused,
> finishing it will merely do onStop() and onDestroy().
>
> > I don't see that in the documentation I read.
>
> Documentation has gaps.
>
> If you can create a sample application that demonstrates that you're
> correct, please post it.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 3.3 Available!
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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