title: How do I keep single instances of my Activities working with the backstack?
body: <p>I have an app with a <code>MainActivity</code> and <code>ChildAaActivity</code> and <code>ChildBbActivity</code>.</p>
  
  <p>MainActivity can send us to either of the Child activities and the user can move between the two Child activities as often as they want.</p>
  
  <p>However, there must only be one instance of each of these activities.</p>
  
  <p>The problem is, if I make the child activities <code>singleInstance</code>, then they are all separate tasks and switching to another app and back to the child means that <code>onBackPress</code> I exit the app (when I should return to MainActivity)</p>
  
  <p>If I leave <code>launchMode</code> as standard, then I get multiple instances of the child activities, especially when moving back and forth between the two children.</p>
  
  <p>If I use <code>singleTop</code>, then I have both problems</p>
  
  <p>If I use <code>noHistory</code> on the children I can't freely move between them (first back press would return me to MainActivity)</p>
  
  <p>Using <code>isTaskRoot()</code> obviously wont work with <code>singleInstance</code> to fix the app exiting bug, because it will always be true (and isn't useful for the other scenarios)</p>
  
  <p><strong>How should I correctly achieve the behaviour I need?</strong> </p>
  
  <ul>
  <li>Only one instance of each Activity in the back stack</li>
  <li>All in the same task / don't exit onBackPress after switching apps</li>
  </ul>