title: Android lifecycle weirdness with singleTop and foreground service?
body: <p>Here's the scenario:</p>
  
  <ul>
  <li>Start Activity A</li>
  <li>Activity A starts service S</li>
  <li>Service S runs in foreground mode and shows up a notification which when pressed takes the user to Activity B (which has launchMode="singleTop")</li>
  <li>Activity B shows up</li>
  <li>Press HOME</li>
  <li>Go into DDMS and kill your application process to simulate that your app died (press red STOP button)</li>
  <li>Android will say "Rescheduling crashed service in 5000ms" (sometimes longer)</li>
  <li>Service S restarts and notification is shown.</li>
  <li>Press the notification icon when the service restarts...</li>
  </ul>
  
  <p>...at this time, Android will recover both Activities A and B due to the fact the process ended unexpectedly. But despite the fact Activity B is singleTop android will spawn it AGAIN because the user clicked on the notification. This results into having A -> B -> B on the activity stack. Pressing back will take you again onto the first recovered instance of Activity B.</p>
  
  <p>Can someone from the Android team clarify what is happening behind the scenes and how to avoid this? What is the best way to simulate that Android killed the process due to low memory? Is pressing STOP from DDMS good enough or an edge case and this should never happen under normal circumstances?</p>
  
  <p>What is the difference between 'Force Stop' from Settings --> Applications versus STOP from DDMS?</p>
  
  <p>Thanks in advance!</p>