I'm developing an app using Swipe tab that contains 2 fragment. I have an AsyncTaskLoader in Fragment 1 to load data from database and display in a ListView, an AsyncTask in Fragment 2 to parse JSON data from server and display in a ListView too. It seems work fine but sometimes I got crash because of window leak blah blah. The question is how to make the AsyncTask in Fragment 2 only run when I swipe into it? Now, when I start my app, the AsyncTask runs even I'm in Fragment 1.
Thanks