title: Android, how to bring a Task to the foreground?
body: <p>My question: </p>
  
  <p>How can I launch a new Activity in its own Task while using the following rules.  </p>
  
  <p>1) If the Activity already exists as a root of a another Task (within the same application)  then bring the Task to the foreground.  I don't want another instance of the Activity to be created. I just want the Task that it is the root of to come to the foreground and the top Activity of the Task to be displayed. </p>
  
  <p>Note: it will only be the root of one Task at a time and it will only exist as the root of the Task and nowhere else.</p>
  
  <p>2) If the Activity doesn't exist then create this Activity in its own Task.  </p>
  
  <p>Why I'm trying to achieve this? 
  I created four bottoms at the bottom of my Activities that should behave like tabs.  So if I press the second "tab" I want the Activity that is associated with that tab to be displayed. But if it already exist and is on the bottom of its own Task then I would like that Task to be displayed with whatever Activity that is currently on the top of the Task.  </p>
  
  <p>What have I tried so far? 
  I've searched stackOverflow and couldn't find a similar question.  I read <a href="http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html" rel="noreferrer">http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html</a>
  and <a href="http://blog.akquinet.de/2010/04/15/android-activites-and-tasks-series-intent-flags/" rel="noreferrer">http://blog.akquinet.de/2010/04/15/android-activites-and-tasks-series-intent-flags/</a>   </p>
  
  <p>I think I need to use either FLAG_ACTIVITY_NEW_TASK and/or affinities but not sure. Looking for a hand please.  </p>
  
  <p>Thanks, 
  Bradley4</p>