I am trying to create an 'auto-refresh' function in my application - so if one activity or fragment has been in the background for more than two minutes, it will automatically fetch new data from the api when entering the foreground.
However i have a case where Fragment A in Activity A, does the api call and shows the data in a list. When clicking a specific list element, you enter Activity B, where more information is shown.
Problem is - instead of making a api call for the specific listelement, when activity B enters the foreground after being in the background for at least two minutes - i'd rather just get the whole list (it's dynamic and usually pretty short) and ideally use the same code i use for the initial fetch in fragment A.
Is it possible to call a method from Activity B in Fragment A? How do i do it? And how do i pass the data back to Activity B afterwards, to update the UI there?
So i have a stack looking like:
Activity B (Foreground)
Fragment A in Activity A
And i want to call a method in Fragment A, from Activity B - and report back to Activity B, when the http request has responded.
Thanks in advance and please let me know if there is anything i need to elaborate.