title: Android: Dialog etc restore after rotation changed
body: <p>How to restore the dialog etc after rotating the screen? For example, pop up an alertDialog to tell user some information. then the user rotate the screen to another orientation. How to restore the alertDialog? Can any one guide me to do it? Thanks!</p>
  
  <p>Appended later:</p>
  
  <p>I looked into the android source code and find these things:</p>
  
  <p>Dialogs are stored in <code>mManagedDialogs</code>, and the related information is:</p>
  
  <pre><code>mManagedDialogs = new SparseArray&lt;ManagedDialog&gt;();
  </code></pre>
  
  <p><code>onSaveInstanceState</code> related:</p>
  
  <pre><code>final void performSaveInstanceState(Bundle outState) {
      onSaveInstanceState(outState);
      saveManagedDialogs(outState);
  }
  </code></pre>
  
  <p>In <code>saveManagedDialogs</code>, it has something to do with <code>mManagedDialogs</code>.</p>
  
  <p><code>onRestoreInstanceState</code> related:</p>
  
  <pre><code>final void performRestoreInstanceState(Bundle savedInstanceState) {
      onRestoreInstanceState(savedInstanceState);
      restoreManagedDialogs(savedInstanceState);
  }
  </code></pre>
  
  <p>In <code>restoreManagedDialogs</code>, it has something to do with <code>mManagedDialogs</code>.</p>
  
  <p>As you can see, for advanced feature, you must do the saving and restoring job by yourself. It may be a night mare when you have tons customized dialogs. I have not tried the complex dialog (has input EdiText, listView, say). In this way, I'd like to warn users: Never rotate the screen when inputing your info in the dialog... OR, lock the rotation dynamically when showing the dialog. </p>
  
  <p>Thanks for all the people who answered me. Hope my information help you too.</p>