title: android launchMode="singleTop" in two activities
body: <p>I have two activities in my app that have the <code>android:launchMode="singleTop"</code>.  It works as expected.</p>
  
  <p>My purposes for having <code>singleTop</code> is to update them partially without having to recreate the entire activity from scratch.  A sample execution goes like this.</p>
  
  <p>A -> B</p>
  
  <p>when backpressed from B, display in A is updated.</p>
  
  <p>A -> B -> C</p>
  
  <p>when backpressed from C, display in B is updated.</p>
  
  <p>However, when I flip the display to trigger an orientation change while activity B is on top (from backpressing from C), B is mysteriously destroyed and A is displayed instead.  Why is this happening?  Does android allow more than one activity to have the <code>singleTop</code> behavior?  Should I pass other flags from C to B to prevent B from closing if an orientation change happens?</p>
  
  <hr>
  
  <p>Code for above feature:</p>
  
  <p>ActivityA</p>
  
  <pre><code>@Override
  protected void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      setIntent(intent);
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      Intent intent = getIntent();
      if(intent.hasExtra(UPDATE_ARG)) {
         ...
      }
  }
  </code></pre>
  
  <p>ActvitiyB</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      super.onBackPressed();
      Intent intent = new Intent(this, ActivityA.class);
      intent.putExtra(ActivityA.UPDATE_ARG, true);
      startActivity(intent);
  }
  
  @Override
  protected void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      setIntent(intent);
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      Intent intent = getIntent();
      if(intent.hasExtra(UPDATE_ARG)) {
         ...
      }
  }
  </code></pre>
  
  <p>ActivityC</p>
  
  <pre><code>@Override
  public void onBackPressed() {
      super.onBackPressed();
      Intent intent = new Intent(this, ActivityB.class);
      intent.putExtra(ActivityB.UPDATE_ARG, true);
      startActivity(intent);
  }
  </code></pre>
  
  <p>And in the manifest file, both ActivityA and ActivityB have <code>android:launchMode="singleTop"</code> attributes defined.</p>