Question

So I have a download button in my application which starts an ASyncTask to download a binary file. When I rotate the screen it stops the download obviously because the activity is destroyed.

Would there be a way to stop the download from being killed or would I just have to save the state and then restart the download when and if the screen is rotated?

Thanks

Was it helpful?

Solution

AsyncTask which downloading really doesn't stop. But when you rotate phone it recreating and callback trying to update old activity. That's why you don't see result. To avoid this you need to user loaders (http://developer.android.com/guide/components/loaders.html). Look at AsyncTaskLoader, it similar to AsyncTask, but provide mechanism to avoiding your problem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top