2

I am trying to get a handler to start as soon as the fragment appears on screen to the user. I have tried many other ways and they all seem to start the handler thread before the fragment appears to the user. Usually the fragment before triggers it.

The isVisible() method that is floating around other threads says a fragment is visible when it isn't on the screen.

Any help is appreciated!

Bugsy
  • 21
  • 3
  • 1
    possible duplicate of [How to test if a fragment view is visible to the user?](http://stackoverflow.com/questions/9323279/how-to-test-if-a-fragment-view-is-visible-to-the-user) – Jared Burrows Aug 05 '15 at 14:44

1 Answers1

1

One way to handle it is with the getUserVisibleHint() or setUserVisibleHint(boolean isVisibleToUser Method of the Fragment. The other way would be to add a ViewPager.OnPageChangeListener and in the onPageSelected method you know the position of the selected fragment and react to it.

Arne Poths
  • 76
  • 4