I have the following situation:
I have an Activity
that hosts a ViewPager
, and I have 4 Fragments
;
the ViewPager
Check out the solution from my answer here
1) Create LifecycleManager
Interface The interface will have two methods (onPauseFragment
and onResumeFragment
) and each ViewPager
’s Fragment will implement it
2) Let each Fragment implement the interface
3) Implement interface methods in each fragment - start your AsyncTask
in onResumeFragment
4) Call interface methods on ViewPager
page change You can set OnPageChangeListener
on ViewPager
and get callback each time when ViewPager
shows another page
5) Implement OnPageChangeListener
to call your custom Lifecycle methods