Try storing the newly spawned thread as a field or collection in the
appropriate class.  Then when you need to kill the thread, retrieve it
and call Thread.interrupt().

Matt

On Dec 9, 6:15 pm, Richard Zhao <zwher...@gmail.com> wrote:
> My problem is:
> Activity A called Activity B, and in Activity B, it start a background
> thread to do some client-server work. But it maybe takes too much
> time. So i add a cancel button to call the stop() method to stop the
> thread, and call finish() to finish the Activity B and go back to
> Activity A. Although it is back to Activity A, the thread isn't stop
> immediately.
>
> Can i just call the finish() to go back to Activity A, and leave the
> thread to exit by itself?
> If it is not the right way, which is?
>
> Thanks for any help.

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