Yes, you can safely use activity references in onPreExecute and onPostExecute, because those are run on your application's main thread, the same thread that all framework components run on. So by referencing your activity in onPreExecute and onPostExecute you wont need to contend with with any synchronization issues. Be aware though, the activity you reference in onPreExecute and the activity you reference in onPostExecute *may* be different activity instances, if the screen was rotated. That's why it was suggested that you use the global application context, obtainable by Context#getApplicationContext, if a context is all that you need.
If you do need the activity reference for doing other things, like showing or closing dialogs, Mark's sample project, linked to in his article that I posted, shows a few ways of handling this. Activity#dismissDialog, and maybe Activity#removeDialog, too, throw nasty IllegalStateExceptions if you try to close a dialog that hasn't been opened, which can easily occur if you show a dialog in onPreExecute, then try to close it in onPostExecute, if the screen has rotated and the activity reference changed. So if you're doing this, please pay close attention to Mark's example project. On Oct 26, 4:58 pm, Bluemercury <[email protected]> wrote: > Hey Skyler, thanks for the link. so i need to get rid of activity reference > on the doInBackground...i assume its possible to use the activity reference > in the preExecute and post.... -- 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

