[android-developers] Re: Avoid restarting background threads on orientation change

2010-05-20 Thread Jeff
Ok, I believe I have made a little progress on this. It looks like I can use onRetainNonConfigurationInstance() to save an instance of my thread objects and then call getLastNonConfigurationInstance() to get them back when the Activity is restarted. This leads me to a new questionwhen do I

Re: [android-developers] Re: Avoid restarting background threads on orientation change

2010-05-20 Thread Mark Murphy
This leads me to a new questionwhen do I actually destroy the threads then? As soon as their work is done. All else being equal, choose a model where you do not keep your own threads hanging out forever (e.g., use AsyncTask rather than forking your own threads). Part of me is wondering if

Re: [android-developers] Re: Avoid restarting background threads on orientation change

2010-05-20 Thread Jeff Thorn
As always, thanks Mark! I definitely see your point - its better to do short chunks of work in an AsyncTask than creating long running background threads. My app makes a lot of http requests. After the download is complete, it updates a database. I thought it would be better to create a single

Re: [android-developers] Re: Avoid restarting background threads on orientation change

2010-05-20 Thread Mark Murphy
My app makes a lot of http requests. After the download is complete, it updates a database. I thought it would be better to create a single background thread that does this work and then notifies the UI when its finished. I thought this would be more efficient than opening a network

Re: [android-developers] Re: Avoid restarting background threads on orientation change

2010-05-20 Thread Jeff Thorn
I took your advice and refactored my code to replace any long living background threads with AsyncTasks. Wow!!! I cannot begin to tell you how much it simplified my code. Thank you so much for the very valuable advice. On Thu, May 20, 2010 at 10:17 AM, Mark Murphy mmur...@commonsware.comwrote: