i have an activities that host fragments. pressing a button goes from fragment A to fragment B through a FragmentTransaction and the added to the back stack. Now fragment B has an AsyncTask implementation which loads images from an sdcard and publishes it as an image is loaded. if i press the Back button, my app crashes. . The error report indicates that the async task is the problem as it was still loading when the Back button was pressed, so my question is, how can i or where should i stop the AsyncTask when the Back button has been pressed to return to the previous fragment/activity?.. Thank you.
Share
Override the onStop() of your fragment and do: