In addition to what Mark has pointed out keep in mind that when the
device is rotated the activity is restarted but not the asynctask. So
you will end up with a null activity variable. It is fairly well
documented on the android developer site how to deal with device
rotation or configuration changes.

On Mon, May 16, 2011 at 7:39 PM, Mark Murphy <mmur...@commonsware.com> wrote:
> On Mon, May 16, 2011 at 7:37 PM, elioncho <elion...@gmail.com> wrote:
>> I have an AsyncTask (in a separate file) which is invoked on an
>> activity. When I instantiate the AsyncTask, I send the activity as a
>> param. How can I access the acitivity's instance variables from the
>> onPostExecute method of the AsyncTask?
>
> Make the instance variables package-protected, and put both classes in
> the same package.
>
> Or, more cleanly, implement getter/setter methods on the activity that
> the AsyncTask can use.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training in London: http://bit.ly/smand1, http://bit.ly/smand2
>
> --
> 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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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