I have created a project with Jet-pack Navigation graph. In my project everything is working fine. But I am facing a problem that Suppose that We have 2 three fragment A and B. In Fragment A in the onViewCreated() method i call a API. Now I move From From Fragment A to B Using the action. it work fine but when i Go back to the Fragment B to A using popBackStack() or navigateUp() then the API of Fragment A is Again call.
So I Can't find the way that how can i save the state of the fragment and API will call only one time when the fragment is created first time. after that when we go back to the fragment then API will not call.
So Please suggest me that how can achieve this behaviour of fragment in the navigation graph.