How can the fragment understand that it has “paused”? This means that he was covered by another fragment, for example. In fact, the fragment does not have an onPause () method, but how can it be traced? I will be very grateful!

  • Why doesn't it have onPause? And still there is setUserVisibleHint(boolean isVisibleToUser) - called when the visibility changes. Describe in more detail why you need it and the task in general - maybe you are trying to solve it in the wrong way - YuriySPb
  • @ YuriySPb thanks for the answer. At first I read in one source that there was no such method, I pointed it out and then I discovered it on the developer android site - it turns out there is. This is a question on the courses asked, I literally and described. 2 options are better than one)) - v.podlipnyak

1 answer 1

The life cycle of fragments is similar to the life cycle of activities. Fragments also have an onPause() method that can be overridden to track the pause state.

enter image description here