On Mon, Oct 3, 2011 at 5:28 PM, Studio LFP <[email protected]> wrote:

> When this happens, you need to save off the position in your AsyncTask and
> restart it back when the activity gets restarted.


The OP is using getLastNonConfigurationInstance(), which would indicate he's
keeping the same AsyncTask instance across the application restart, so he
wouldn't have to restart the AsyncTask.

2011/10/3 João Rossa <[email protected]>

> Well when i rotate, either while the thread is started or after the screen
> data is refreshed it goes back to the fields having not been filled. but the
> thread does run because if i dont rotate the UI views are filled with the
> content i fetch from the server.


Looks like you AsyncTask is an inner-class of your Activity, which means
that when you start it, it has an implicit reference to the Activity that
started it. When you rotate the device, that Activity is destroyed but your
AsyncTask is still holding on to it, so when you do findViewById() in your
Runnable, you're acting on the old instance that is no longer visible.

One thing you can do is make the AsyncTask *not* an inner-class and give it
an *explicit* reference to the Activity it's working on, then reset that
instance to the new Activity once your activity is restarted.

Or something like that.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

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

Reply via email to