I have an application that uses AsyncTasks to make calls to a REST server.
Imagine that during a loading period (this is, the AsyncTask going to the REST server and gets data to the next screen) the user presses Home.
What is recommended:
- Cancel the current AsyncTask(s) and restart when resuming the Activity
or
- Continue the AsyncTasks but avoiding the startActivity by checking if the app is on background (to avoid the foreground of the new activity after sending the app to background). And onResume sending to the next activity
Worst case scenarios that you should foresee:
- The app goes to background and is killed due to lack of memory
- The asynctask fails due to timeout or other REST error
After both, the user goes back to the app...
If you wanna ask how to do any of the two ways you have mentioned then its a different case.
Please tell if that is what you needed. – akkilis Jan 11 '12 at 12:14