0

I have 3 Activities A B C ::--

I call API for departments list in activity A and each departments has multiple managers with managers details like name , mobile , emails etc.

Activity A (contains department list) Activity B (contains Manager list for particular department) Activity C (contains One manager personal details like name , mobile ,email) etc.

Activity A starts activity B Pressing Back on activity B should lead to A Activity B starts activity C Pressing Back on activity C should lead to B

In Activity A I get data form API for List View ( Department List). I pass this data in activity B though intent on list view item click (click of department Cell which contains multiple manager list) and now I have list view for managers list and now on click of manager list item I pass data of that particular manager details in Activity C though intent now I call API for updating manager details after successful response of API I want to refresh activity B to refresh manager list how can I do this

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
Laksh Lathiya
  • 322
  • 2
  • 12
  • Lets say the updated manager details are coming in the department api and whenever you update any manager detail i am guessing that api has updated data. So in your case you call departments api in Activity A and when you click any item all its details are sent to Activity B. So in your case when you updated manager details in Activity C on success of the api, you can go back to Activity A and then click on the same item and it will take you to Activity B where you can see the updated reponse. – Hascher Mar 07 '21 at 18:24
  • Whe you finish actvity C, try to use OnActvityResult, see an example her e: https://www.javatpoint.com/android-startactivityforresult-example – Android Killer Mar 07 '21 at 18:24
  • Hascher .. I know that but it can be possible without skiping activitie B .. – Laksh Lathiya Mar 07 '21 at 19:57

1 Answers1

0

3 Options

  1. Just always refresh all managers in Activity B in onResume or onStart - this will ensure you always have the latest information.

  2. Use startActivityForResult or the new Results API to get a result from Activity C. After it updates the manager, pass back the updated information to B and it can use that to update the selected Manager.

  3. Use an "offline first" architecture pattern. Activity B would get it's data from a local (Room) database which it always queries in onResume or onStart, like option 1 but offline. Activity C would update this database once the online fetch completes. On returning to Activity B, the new data is automatically refreshed. Google "android offline first architecture" for more.

dominicoder
  • 9,338
  • 1
  • 26
  • 32