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
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
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
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
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:
5 matches
Mail list logo