Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Fragments saveInstanceState
    primarykey
    data
    text
    <p>I have been working on changing my application from multiple activities to single activity and multiple fragments. I have Multiple Fragments and Single Activity A.</p> <p>Following was my scenario when the application had multiple activities. </p> <ol> <li>Activity A --> Activity B --> Activity C --> Activity D</li> <li>Web request was sent in all activities for every 60secs on the background and then the UI is updated.</li> <li>I was sending request only in the <code>onResume()</code> method and was canceling the request and timer in the <code>onPause()</code> method, because of which only the visible activity sends the request and others don't.</li> <li>I saved a boolean value in the <code>onSaveInstanceState(Bundle savedInstanceState)</code> to check whether the request is sent for the first time. Only if it was first time I would show progress bar and then draw the view. If not (if the activity is restored from back stack) the the progress bar is not shown and the UI alone is updated upon successful response.</li> <li>I moved from Activity A to B. Now the web service request was cancelled in the <code>onPause()</code> method of Activity A. In Activity B's <code>onResume()</code> again a web service was called, progress bar was shown(since its the first time activity is loaded) and the view is drawn. The working is all similar to Activity A.</li> <li>From Activity B I pressed back button and Activity A is resumed. Hence the web service is sent from the <code>onResume()</code> method of Activity A. This time I check the savedInstanceState is not null and hence I don't show the progress bar(to allow the user to still move on to acitivy B and on).</li> </ol> <p>Following is what I'm doing right now after implementing Single Activity and Multiple fragment.</p> <ol> <li>I'm not replacing any fragment. I'm just adding them.</li> <li>Because of just adding them all fragments are actively sending web service in the time interval.</li> <li>If I replace the fragment instead of adding them, the view is created from the first,which is not what I need. </li> </ol> <p>How can I do this?? Thanks in advance!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload