title: Android. Switch between 2 activities without re-creating and finishing
body: <p>I have 2 activities "A" and "B". 
  I need to switch between them without finishing and recreating. </p>
  
  <p><em>Run app -> create and show A -> press button -> create and show B -> press button -> show already exist A -> press button -> show already exist B -> and so on.</em></p>
  
  <p><strong>Current solution:</strong></p>
  
  <pre><code>private void toA() {
      Intent intentToA = new Intent(this, A.class);
      intentToA.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
      startActivity(intentToA);
  }
  
  private void toB() {
      Intent intentToB = new Intent(this, B.class);
      intentToB.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
      startActivity(intentToB);
  }
  </code></pre>
  
  <p>It works on VM (native, Genymotion - android 4.1). Activities will created only once. And when I switch between them, everyting is okay - no calls of the onCreate or onDestroy. It is exactly what I want.</p>
  
  <p>But when I run same app on real device (Nexus 4 - android 4.3) activities are destroyed and recreated while switching.</p>
  
  <p><strong>on VM:</strong></p>
  
  <pre><code>Run app -&gt; 
  A: onCreate, onResume -&gt; 
  press button -&gt; 
  B: onCreate, onResume -&gt; 
  press button -&gt; 
  A: onResume - &gt; 
  press button -&gt; 
  B: onResume -&gt; 
  ...
  </code></pre>
  
  <p><strong>on Real Device:</strong></p>
  
  <pre><code>Run app -&gt; 
  A: onCreate, onResume -&gt; 
  press button -&gt; 
  B: onCreate, onResume &amp; A: onDestroy -&gt;
  press buttom -&gt;
  A: onCreate, onResume &amp; B: onDestory -&gt;
  ...
  </code></pre>
  
  <p><strong>Note:</strong> Intent flag has no effect on the switch behavior.</p>