I have this scenario:
Android app whit 4 activities:
- Activity1 : Login, call a web service and retrieve data for the second activity ( stored it in an object) and switch to second activity.
- Activity2 : Created with the object result of the webservice call, have a list item, onclick item call another web service and retrieve data for the third activity, then switch control to the third activity
- Activity3 : Created with the object result of the webservice call, have a list item, onclick item call another web service and retrieve data for the fourth activity, then switch control to the fourth activity
- Activity4 : Some data are displayed.
Every Activities except the first have two button, logout and back(if i’m in the activity3 i return to the activity2).
The back button is my problem. I don’t want to call the web service back to the activity. I want to store the result of every web service call in a structure and when i click on back i want to use this to repopulate the activity whit the same data.
Something have any suggestion?
I hope i understand what u want,
You should implement Activity lifeCycle properly, When you open new activity onCreate,onStart and onResume are called, and when you go to next Activity onPause of previous activity is called and then onCreate of second activity is called, onResume ,onStart and then onStop is called from precious activity. and when you came back on first activity then onStart is called and then onResume . whats the different when you come back onCreate is not called, you can implement your webservice on onCreate so when you will come back onStart will call not onCreate so you webservice wont be call.
Here is Activity lifeCycle link in case if you didnt understan what i said. another link