Nice way to handle AsyncTask configuration change
A common task in Android is to perform some background activity in another thread, meanwhile displaying a ProgressDialog to the user. Example of these tasks include downloading some data from internet, logging into an application, etc. Implementing an AsyncTask is fairly a simple job, the big challenge is how to handle it properly when an orientation change occurs.
In this article I will walk though a series of potential solutions to address the screen orientation issues when using an AsyncTask.
So, lets create a proof of concept application that makes use of an AsyncTask which does not handle configuration changes yet, and then present a few solutions.
Here’s the AsyncTask implementation that we will be using during the tutorial:
– doInBackground() – this will be called by the AsyncTask on a background thread, and performs all the heavy work. For the sake of this example, I just wrote a simple…
View original post 820 more words