I currently have a viewpageindicator with three tab 1,2 and 3.
The problem is when i swipe to tab 2, the onActivityCreated from fragment 3 is being called.
At my tab 3 fragment, i will call a asyntask onActivityCreated , therefore when fragment 2 is being switched, it will load a asyntask.
By default, ViewPagers load one Fragment on either side of the current Fragment. To know when a Fragment is in the centre, you could use the onPageChangeListener of the ViewPager in combination with an interface implemented by every Fragment subclass.
Implement this interface in every Fragment
In your Activity class: