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 <goo...@wardco.com> 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 <goo...@wardco.com> 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
>>>
>>>  >
>>>
>>
>>
>
> >
>

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