Kostya, Please clear my following doubts.
Is it really necessary to make my background thread stop all the time when my Application is not getting shown. Cant we make my our Application smart enough so that it should not do anything when our Application is not in the context. Like in above case we can create dialog in onCreateDialog so that it should be attached to the screen and should not be visible when screen is not getting shown. On Wed, Feb 2, 2011 at 7:43 PM, Serdel <[email protected]> wrote: > If think I'll need to go with the flagging approach. Seem the more > 'elegant' way to do this. Thanks for your help Kostya (As usual :>) > > On 2 Lut, 14:56, Kostya Vasilyev <[email protected]> wrote: > > Adam, > > > > Thread not stopping right away is normal, since a thread is there so it > > can do its own thing. > > > > Just make sure that your thread function checks the handler or a boolean > > flag or whatever as often as it can, and stops after it's been set - > > this includes before connecting. > > > > You can also close the socket from the UI thread, which will cause the > > current network operation in the worker to fail with an IO exception. > > > > -- Kostya > > > > 02.02.2011 15:35, Serdel пишет: > > > > > Thank you Kostya. As you have nicely noticed my network code doesn't > > > 'see' any flag so that's not an option for me. Setting the handler to > > > null actually came to my mind but it seem a little bit 'dirty'. What > > > worries me is that if I exit my application, the thread is still > > > working, trying to connect and only after finishing that it can 'see' > > > that it was stopped from outside and doesn't want to communicate with > > > UI :/ > > > > -- > > Kostya Vasilyev -- WiFi Manager + pretty widget -- > 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]<android-developers%[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

