Search code examples
androidandroid-asynctaskprogressdialogorientation-changesandroid-orientation

Android handling orientationg change with model object and ProgressDialog


I have an Android application which retrieves information from the web using an AsyncTask. The main Activity has a model object, and the AsyncTask calls a method on this object to go and retrieve the data. While this is going on, the main Activity fires off a ProgressDialog. As you can imagine, this was not implemented with orientation changes in mind. I know I can save the model object instance away using the onRetainNonConfigurationInstance() method. But what do I do with the ProgressDialog? Can I save that away in the same method? Should I destroy it and recreate it? Or should I do a 3rd thing?

Quick Edit: While I'm on the topic, have any of the Android Engineers actually commented on the proper way to do this?


Solution

  • There have been detailed discussions on how to do this here at SO (here, for example). It definitely is not something simple and requires lot of housekeeping on the part of the developer.