On Thu, Mar 11, 2010 at 1:13 PM, Achanta <krishna.acha...@gmail.com> wrote:

> Its not even passing onStop and onDestroy at some point in the future.
> It is only doing it in some point in the future when more activities
> are started. I tested it 4-5 times and let it run for atleast 5
> minutes. So I don't know how long I have to wait for the thread to
> close.
>

What I was trying to say is that it will not completely forget to destroy it
-- onDestroy() WILL be called, just at some time later.  Possibly a lot
later if the user sits in home for a long time.


> Can anyone suggest a work around for this issue.
> I have a background thread which starts in the onCreate methos and
> which I close in the onDestroy method. But because of this bug in the
> sdk 2.1 my thread never stops. But when the user closes the
> app[onDestroy hasn't been called] and opens my application again, I
> try to create the thread in the onCreate. But after this is done at
> some point the onDestroy from the earlier activity is called which
> sends a messahe to my thread's handler to stop the thread. So the app
> runs now but the background thread doesnot run.
>

This is actually a bug in the app -- there is no guarantee that onDestroy()
will be called before a new instance is created.  For example, if you press
back to exiting the activity and then very quickly start a new instance, the
new instance will be started before onDestroy() because we wait until the
apps are idle until destroying activities.  The bug here just makes this
case a lot more likely to happen.  You should keep the state from two
instances of an activity distinct -- for example if your onDestroy() is
called it should only impact state in the activity being destroyed.

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