title: Clear task when launching from home screen
body: <p>Whenever I re-launch application from home screen it starts launcher activity specified in manifest but when I press back button then application does navigate to activity which was previously minimized by pressing home button:</p>
  
  <p>home -> A -> B -> home -> A -> back -> B</p>
  
  <p>Instead, I expect application should close activity A after pressing back button. Mentioned activities are specified in manifest file as follows:</p>
  
  <pre><code>&lt;activity android:name="A"
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true"
            android:noHistory="true"
      &lt;intent-filter&gt;
          &lt;action android:name="android:intent.action.MAIN"/&gt;
          &lt;category android:name="android:intent.category.LAUNCHER"/&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  &lt;activity android:name="B"
            android:launchMode="singleTop"
  &lt;/activity&gt;
  </code></pre>
  
  <p>I need to clear the history of activity A whenever activity B is launched. This looks like clearTaskOnLaunch="true" does not work with noHistory="true" or when calling finish() manually on activity A. Additionally when either one of noHistory="true" or finish() are specified/called then it is necessary to have launchMode="singleTask" in manifest for activity A, otherwise activity B would be launched from home screen instead of activity A.</p>
  
  <p>How can I clear activity B whenever activity A is launched? Adding finishOnTaskLaunch="true" to activity B in manifest does not help. Both activities do have default affinity. Compile sdk version is 26.</p>