title: Android UI Thread Message Queue dispatch order
body: <p>While working with retain Fragments in Android to hold an AsyncTask during configuration changes, which i guess it's the best approach, some doubts appear in my mind about UI Thread's Message Queue invocation order. </p>
  
  <p>Ex: 
  Imagine this scenario:</p>
  
  <ol>
  <li>Configuration Change occurs, user rotates the device. AsyncTask is running.</li>
  <li>Fragment <code>onDetach()</code> is called</li>
  <li>AsyncTask <code>doInBackground()</code> method finishes</li>
  <li>AsyncTask <code>onPostExecute()</code>is called</li>
  <li>Fragment <code>onAttach()</code> is called</li>
  </ol>
  
  <p>So can UI Thread Message Queue be like this:</p>
  
  <blockquote>
    <p>Queue top -> onDetach() | onPostExecute() | onAttach()</p>
  </blockquote>
  
  <p>I know it cannot, the call to <code>onPostExecute()</code> will wait until the configuration change completes,  as far as i know, but how does that work ? Are the calls from Activities, Fragments life-cycles executed consecutively ?</p>