I have a AsyncTask running perfectly but if the user flips his mobile the AsyncTask automatically stops.
Does anyone knows what kind of precautions can I take or enable any function form AsyncTask, etc?
Thanks.
I have a AsyncTask running perfectly but if the user flips his mobile the AsyncTask automatically stops.
Does anyone knows what kind of precautions can I take or enable any function form AsyncTask, etc?
Thanks.
AsyncTask is great for running things off the UI thread, but it does have few issues and one of them is that configuration changes causes it to stop.
I would recommend looking at the Loader class available in Android, it also allows you to run off the UI thread but handles some of the issues that AsyncTask has. Like for example the configuration change problem.
The Android developer guide for Loaders: http://developer.android.com/guide/components/loaders.html
There is a particular subclass of Loader called AsyncTaskLoader which has basically the same functionality as an AsyncTask but does not have some of the issues like the configuration problem. If you just want to jump in and fix your code, I recommend just using the link below instead of the generic Loader guide above.
AsyncTaskLoader: http://developer.android.com/reference/android/content/AsyncTaskLoader.html