title: Android --- how will startActivity or startActivityForResult affect the logic flow of the current activity?
body: <p>I have this question when I am studying an open source Android project.</p>
  
  <p>I have an activity A1 that calls another activity A2 in its "onCreate" method. However, there are code statements before and after the "startActivity / startActivityForResult" method. I do not know the execution sequence in A1 after the "startActivity / startActivityForResult" method. </p>
  
  <p>The code framework for A1 is listed below : </p>
  
  <pre><code>public void onCreate(Bundle bundle) {
     &lt;code statements before&gt;
     this.startActivityForResult(.....);  // Start A2 here.
     &lt;code statements after&gt;
  }
  
  public void onResume() {
     &lt;code statements&gt;
  }
  
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     &lt;code statements&gt;
  }
  .....
  </code></pre>
  
  <p>I wonder whether A1 would firstly finish its execution cycle (i.e. "onCreate" -> "onStart" -> "onResume" -> "onPause" -> "onStop") before it would call A2, or just firstly finish "onCreate" before calling A2, or has other execution logic ?</p>
  
  <p>Moreover, when A2 returns (finishes) and "onActivityResult" in A1 is called, would A1 then executes "onRestart" -> "onStart" -> "onResume" after executed the "onActivityResult" method ?</p>
  
  <p>Because both A1 and A2 have its own UI, I think that the 2 activities may not execute concurrently with two different threads. Does anyone know the exact execution sequence in this case ? </p>
  
  <p>Thanks in advance for any suggestion.</p>