title: Android : Save application state on screen orientation change
body: <p>I have seen the following links before posting this question </p>
  
  <p><a href="http://www.devx.com/wireless/Article/40792/1954" rel="nofollow noreferrer">http://www.devx.com/wireless/Article/40792/1954</a></p>
  
  <p><a href="https://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state">Saving Android Activity state using Save Instance State</a></p>
  
  <p><a href="http://www.gitshah.com/2011/03/how-to-handle-screen-orientation_28.html" rel="nofollow noreferrer">http://www.gitshah.com/2011/03/how-to-handle-screen-orientation_28.html</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3915952/how-to-save-state-during-orientation-change-in-android-if-the-state-is-made-of-m">How to save state during orientation change in Android if the state is made of my classes?</a></p>
  
  <p>I am not getting how should i override the following function :</p>
  
  <pre><code>@Override
      public Object onRetainNonConfigurationInstance() {
          return someExpensiveObject;
      }
  </code></pre>
  
  <p>In my application i have layout with one editext visible and other editext get visible when  the data of first editext validates to true.I have set the visbility of all other editextes and textviews to false and make them visible after validating.</p>
  
  <p>So in my activity if the screen orientation is changed then all the items having <code>android:visibility="false"</code> get invisible.</p>
  
  <p>I have also came to know that when our activities screen orientation changes it calls onStop() followed by onDestroy() and then again starts a fresh activity by calling onCreate()</p>
  
  <p>This is the cause .. But i am not getting how to resolve it ..</p>
  
  <p>Here You can see the screenshots of my application :</p>
  
  <p><img src="https://i.stack.imgur.com/AqD1G.png" alt="enter image description here">
  in this image all fields are loaded 
  and in another image when the screen orientation is changed to landscape they are all gone</p>
  
  <p><img src="https://i.stack.imgur.com/eLXnv.png" alt="enter image description here"></p>
  
  <p>Any link to tutorial or piece of code will be highly appreciable.</p>
  
  <p>And also <strong>my application crashes when a progress dialog</strong> is shown up and i try to change screen orientation.How to handle this ??</p>
  
  <p>Thanks</p>