Hi, Basically you cannot "reuse" an instance of AsyncTask, in the sense of starting it again. As soon as the task is finished you can only get the results out of it and throw it away. And I guess the latter is what you need to be able of after a configuration change happened. You can "re-attach" to an AsyncTask by saving a reference in Activity#onRetainNonConfigurationInstance() and getting that reference back in Activity#onCreate() by calling Activity#getLastNonConfigurationInstance() .
I crafted myself a little helper class [1] which makes this approach a little easier. Though, I'd suggest to not use AsyncTasks too often for long running actions. You can get quickly into trouble in connection with the Activity lifecycle. Maybe an IntentService is a good alternative: you can fire off an Intent to start the work and as soon as it is finished you send back the results with a Broadcast (maybe by utilizing LocalBroadcastManager [2] or some other bus system). [1] https://gist.github.com/4257045 [2] http://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html Am Montag, 10. Dezember 2012 10:38:58 UTC+1 schrieb monty: > > Hello > > > is this possible to save AsyncTask class object on rotation and reuse it > again. > > public class MyTask extends AsyncTask<Void, Void, Integer> > { > > } > > i am using 4.03 version > > any good solution. Thanks > -- [image: Facebook]<http://www.facebook.com/pages/FINARX-GmbH/159293750854154> [image: XING] <http://www.xing.com/companies/finarxgmbh/about> -- 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

