I solved this by having a special application object containing a link to a background thread (AsyncTask in my case). The application object remains alive as long as your process runs. In other words, he will not be killed if your activity dies, for example, if you change the orientation of the phone. Activity set the current activity in AsyncTask at creation and disabled activity in AsyncTask when activity disappeared. AsyncTask will clear its own link from the application object after it is completed. I wrote about it here .
source share