And actually, there is no need to always remove threads.  You don't want to
have threads continue doing work (just like you don't want to continue
pumping messages through your main thread), but a thread just sitting there
blocked in the kernel is not going to consume any significant resources.

In fact you will find lots of things in the framework itself that create
threads and don't try to remove them -- the binder IPC thread pool, the
AsyncTask thread pool, etc.

On Mon, Feb 14, 2011 at 12:32 PM, Kostya Vasilyev <[email protected]>wrote:

>  Application (taken to mean the application's process) != Actvity (or
> Service or Receiver or ContentProvider, substitute your own component here).
>
> It's true that you should shut down any unneeded tasks and threads in your
> activity's onDestroy (actually, more like onPause), but the process is kept
> around.
>
> Quoting from the Dev Guide (emphasis mine):
>
> http://developer.android.com/guide/topics/fundamentals.html#procthread
>
> *Android may decide to shut down a process at some point*, when memory is
> low and required by other processes that are more immediately serving the
> user. Application components running in the process are consequently
> destroyed. A process is restarted for those components when there's again
> work for them to do.
>
>
> http://developer.android.com/guide/topics/fundamentals.html#proclife
>
> *The Android system tries to maintain an application process for as long
> as possible*, but eventually it will need to remove old processes when
> memory runs low. To determine which processes to keep and which to kill,
> Android places each process into an "importance hierarchy" based on the
> components running in it and the state of those components. Processes with
> the lowest importance are eliminated first, then those with the next lowest,
> and so on.
>
>
> -- Kostya
>
> 14.02.2011 23:10, Kevin Duffey пишет:
>
> I am curious why if in your onDestroy you shut down any tasks/threads, your
> app would still show up? I would think it would exit properly if you wanted
> it to. Perhaps I misunderstood that. I thought if the lifecycle onDestroy
> fires, that meant your app (or at least the activity) was going to be done.
> If you only have one activity then your app should essentially close. If
> your app is made of multiple activities, then calling finish() does that not
> end the activity? Assuming you have 3 or 4 running, and you call that on all
> of them, wouldn't your app shut down?
>
> I see I still need to learn more on the lifecycle stuff.
>
>
> On Mon, Feb 14, 2011 at 11:42 AM, Kostya Vasilyev <[email protected]>wrote:
>
>> 14.02.2011 22:28, John пишет:
>>
>>  A user who has downloaded my app probably won't take time to ask me
>>> why my app is still running. He will merely look at the task manager
>>> and form a bad opinion of my app.
>>>
>>
>>  Yes they can. However, not all users use task killers, and among those
>> who do, some do email and ask.
>>
>>
>>  Misguided as this user may be, I have an unverified belief that many
>>> such users exist.
>>>
>>
>>  Some do, and sometimes they post bad comments that may or may not affect
>> other user's perception of your app. In general, users are just human, and
>> they can misjudge any particular feature or lack thereof and complain.
>>
>> This used to really get on my nerves, now I'm a few months older and a few
>> notches wiser - or just more cynical, but that's healthy cynicism.
>>
>> And speaking of that:
>>
>> http://en.wikipedia.org/wiki/Cynicism
>>
>>  They believed [...] suffering was caused by false judgments of what was
>>> valuable and by the worthless customs and conventions which surrounded
>>> society
>>>
>>
>> It fits perfectly - in this case, suffering is caused by the false
>> judgment that a task killer is valuable, and by the worthless custom and
>> convention of downloading and using one :)
>>
>>
>> --
>> Kostya Vasilyev -- http://kmansoft.wordpress.com
>>
>> --
>>   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
>>
>
> --
> 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
>
>
>
> --
> Kostya Vasilyev -- http://kmansoft.wordpress.com
>
>  --
> 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
>



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