I have an Activity that runs a simple AsyncTask. To keep the AsyncTask running during screen rotations I am using onRetaingNonConfigurationInstance() to pass the AsyncTask to the new Activity as recommended in one of the answers from the thread How to handle an AsyncTask during Screen Rotation? Then I update a pointer to the Activity in the AsyncTask to make sure it can still update the progress dialog from on onProgressUpdate().
My problem is that using this method I cannot detect if the Activity is only rotated (In this case I want to continue to run the AsyncTask) or if the Activity is hidden by the Home button in which case I'd like to stop the AsyncTask. I can however detect the usage of the back button because in this case the isFinishing() of the Activity returns true;
Is there any mechanism I could use to differentiate rotation versus home button usage?