0

I have a ViewPager adapter controlling fragments that display various information. When a fragment is about to be swiped out and become invisible, I'd like to receive a notification. For the Fragment class, there are functions being fired off when the fragment view or fragment is about to be destroyed, but the fragment is not destroyed, just not visible, so I am not getting any notifications.

Thank You, Gary

Gary Kipnis
  • 722
  • 14
  • 33

1 Answers1

1

Just like Activity, the Fragment gets a callback in onPause() when the fragment is able to become invisible. So, you can implement onPause() in your fragment class to get notification. Hope it helps.

Mei-Lin
  • 286
  • 2
  • 4
  • 1
    The paging adapter keeps N number of fragments available to the left and right of the current fragment. The fragment is only paused, when it scrolls past this N boundary. The fragment does not receive an onPause() message when it becomes invisible. – Gary Kipnis Mar 29 '14 at 02:27