onSaveInstanceState(), onDestroy() and fragment's onCreateView()?
===

I have an activity which contains a ViewPager with 2 pages / fragments.

The activity calls webservice in onResume() in order to populate the fragments with data.

If the activity is destroyed, I expect:

1. The activity calls the webservice again, populating the fragments again with the response's data.

2. The state given by the user is restored.

Point 1. should be already solved by the fact that the webservice is called in onResume(), so the response will populate the fragments again.

In order to achieve 2. I implemented onSaveInstanceState() in the activity and in the fragments. In the activity I save the state related only to the activity, like the current page the user is in, and in the fragments I save state like the text a user entered in an input field.

But it seems something is wrong with my approach of combining the webservices with onSaveInstanceState, because in a test, after the activity was destroyed, the fragment's onCreateView() was called immediatly (with the bundle I saved), but there the webservice has not even been called, so the adapter/fragments have not been initialized with the response's data yet and I get nulls everywhere in onCreateView() when accessing this data.

So what do I have to do, I would save the entire state in the activitie's onSaveInstanceState(), but it will call anyways the webservices again in onResume() and instantiate the adapter again... after I restored my saved state...

Any help greatly appreciated, thanks. 

