title: Android, using appropriate intent flags
body: <p>It is the first time I try to use intent flags in up navigation, and I am getting confused which are the right intent flags to use. My application tree is:</p>
  
  <pre><code>  A    
   / \   
  B   S   
  |   |   
  C   W   
  |   |   
  D   D
  </code></pre>
  
  <p>The main activity is A, S is a searchable activity. The state of activity S and W are saved. When navigating up from D, it goes to C, then B and A. It is the same for S, W, D.</p>
  
  <p>My best approach is using: <code>intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);</code> in all intents. Everything works ok in 2.3.3 but when I try in 4.2 activities are destroyed when navigating up. For example, when I go: A-S-W then I navigate up to S, S is resumed. The problem occus in this scenario: A-S-W-D then navigate up to W. In this case W and S are destroyed and A is resumed. The same happens in this other case: A-B-C then navigating up brings to B, and when A-B-C-D then navigating up brings to A.</p>
  
  <p>As far as I understand, using FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_SINGLE_TOP finishes the calling activity and if the called activity is in the stack, it doesnt create a new instance. But this is not happening.</p>
  
  <p>So why the activities are destroyed? Which are the correct flags to use in this simple case?</p>