Good morning,

I'm a little confused how to correctly handle tasks (AsyncTask) when
the screen orientates.

The documentation states that the object passed to
onRetainNonConfigurationInstance should have no refererence to the
destroyed activity/context. When i pass a pointer to a AsyncTask it
shouldn't have such a reference.

But in the AsyncTask onPostExecute() method (which is executed in the
UI thread) the result of the task should be displayed in the fields of
a activity.

How can i display the result of a AsyncTask in a activity when i may
not use anything that references to the destroyed activity?

For example i can't pass my EditBox to the constructor of the
AsyncTask, because it is a reference to the activity that will be
destroyed, but i do want to put the result of the task in that
EditBox ;-)

I buzzles me.

One solution comes in mind and that is to save the pointer to the task
in onRetainNonConfigurationInstance() and restore it in onCreate().
Then call a method on the task class and pass a pointer to the new
EditBox. But it isn't 100% save, cause while the screen is rotating
(things are destroyed/created) the task might finish and cause
unpredictable results.

Can anybody give me advice on this subject?

Kind regards,
Twan
--~--~---------~--~----~------------~-------~--~----~
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