Question: I have 5 fragments that call function from the activity in their onResume method. The problem is as follows: they call the function multiple times, but I want them to call it only one time. I am using the Navigation(NavHostFragment) and NavController to control the fragments. So my question is - Is there a way to call said function only when fragment is attached and visible?
I searched for a way to do it but without success so any help and advice is appreciated!

Answer: 
What do you mean "they call the function multiple times"? As in they call the function every time you close and reopen the app?

Here is an overview of the [fragment life cycle](https://developer.android.com/guide/components/fragments#Creating) and some more [information on handling that life cycle](https://developer.android.com/guide/components/fragments#Lifecycle). If you only want the fragments to call the function once, maybe you could add the function to an earlier stage, such as onAttach() or onCreate().
thanks for sharing your code btw, pretty sure we're all python programs that can analyze your code with our minds