title: back navigation behavior on android
body: <p>I have some activities in my app:
  <strong>A</strong> - Login Activity
  <strong>B</strong> - Main app Activity
  <strong>C</strong>, <strong>D</strong> ... - Inner Activities
  I want to implement a behaviour as follows:</p>
  
  <ol>
  <li>when a user select the app icon OR select the app from the task list I want the back stack to be cleared and show Activity <strong>A</strong></li>
  <li>when a user passed <strong>A</strong> pressing the back on activity <strong>B</strong> will quit the application</li>
  <li>when a user in an inner app pressing back will function "normally".</li>
  </ol>
  
  <p>for example: activity stack <strong>A</strong> -> <strong>B</strong> -> <strong>C</strong> -> <strong>D</strong>  pressing the back button the first time (top activity is <strong>D</strong>) will make pop the <strong>D</strong> of the stack top and it will be: <strong>A</strong> -> <strong>B</strong> -> <strong>C</strong> clicking again (top activity is <strong>C</strong>) will move us to <strong>A</strong> -> <strong>B</strong> and clicking again will quit the app (as described in 2)</p>
  
  <p>I implemented (2) by adding <code>android:noHistory="true"</code> to <strong>A</strong>'s properties in <code>AndroidManifest.xml</code>
  and tried to implement (1) by adding <code>android:launchMode=singleTop</code> to  <strong>A</strong>'s properties in <code>AndroidManifest.xml</code> but when I do that (3) is breaked and clicking back when  <strong>D</strong> is visible moves me directly to <strong>A</strong>.</p>
  
  <p>how can I implement them all?</p>
  
  <p>Thanks!</p>