onStop() should be the correct place to do this kind of stuff. Also, note that in the case mentioned (user pressing home) you do not go to the bottom of the stack; home is brought up to the top. If there was anything besides home below you, it will still be below you. For what it's worth. :}
On Mon, Mar 23, 2009 at 5:09 PM, Stoyan Damov <[email protected]>wrote: > > As a hack, you could do this (depends on how many activities you have, > whether they cover the entire screen, etc.): > > Let's say you have activity A, which launches activity B. > Activity A is the one spawning the threads. > Now, apparently, you know when you're launching activity B, so you > could do something like this: > > // in activity A, before launching activity B > mPausedBecauseLaunchedActivityB = true; > > // in onPause in activity A > if (!mPausedBecauseLaunchedActivityB) > { > // Activity A is being paused because another activity (surely a > different app) is on top of yours, e.g. Home > // STOP the threads here > } > > // in onResume in activity A > if (!mPausedBecauseLaunchedActivityB) > { > // Activity A is being resumed after it's being paused because of > another activity (not one of yours) > // RESTART the threads here > } > > HTH, > Cheers > > On Tue, Mar 24, 2009 at 2:01 AM, Ward Willats <[email protected]> wrote: > > > > Thanks for the response Stoyan. I like having the UI preserved so I > > don't want to toss everything down to the root. I just want to stop > > some worker threads when going into the background. > > > > > >>See if "clearTaskOnLaunch" [1] is not what you're looking for. > >> > >>[1] http://developer.android.com/guide/topics/fundamentals.html > >> > >>Cheers > >> > >>On Tue, Mar 24, 2009 at 12:57 AM, Ward Willats <[email protected]> > wrote: > >>> > >>> Is there a way to tell when my task gets put on the back of the UI > >>> stack (user pressed "home" say?) I have some resources I'd like to > >>> free when not foregrounded. > >>> > >>> The lifecycle routines seem dicey to use to try and infer this. > >>> > >>> The "home" key does not seem to be passed to onKeyDown(), and > >>> moveTaskToBack() is never called by the system so I can hook it. > >>> > >>> I can poll the ActivityManager for running activities with my task > >>> id, but hard to find a good time to call this. > >>> > >>> Thanks > >>> > >>> -- Ward > >>> > >>> > > >>> > >> > >> > > > > > > > > > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. 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 [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 -~----------~----~----~----~------~----~------~--~---

