title: Clear back stack after activity is opened from web-browser by url "appname://com.appname/"
body: <p>My application has an activity, that launches oauth-authorization process in browser, and finally browser receives redirect to url "appname://com.appname", that calls back to my activity. (activity declared that it can view such urls)</p>
  
  <p>Everything is OK, but if user presses "Back" he goes back to web browser.
  I want to clear history stack when activity is called back, to make this activity root and top in this task.</p>
  
  <p>What flags or hooks can I use for this case?</p>
  
  <hr>
  
  <p><strike>
  I found only one ugly solution:
  receive appname://com.appname urls to special "Gag" activity, that will launch main activity on its onResume.</p>
  
  <p>I tried to make main activity "singleTask", launch browser in new task, set flags NO_HISTORY and EXLUDE_FROM_RECENTS, CLEAR_TOP, set clearTaskOnLaunch="true".
  Tried many combinations of that flags and tags in manifest - nothing helps.
  </strike></p>
  
  <hr>
  
  <p>I solved this problem:<br>
  1) set clearTaskOnLaunch="true" in AndroidManifest.xml<br>
  2) Launch browser in new task (with FLAG_ACTIVITY_NEW_TASK), and finish current activity(to finish current task).<br>
  3) override onBackPressed: instead of finish this activity call to moveTaskToBack(true);  </p>
  
  <p>when user presses back - task(browser is in root of it) goes to background and user see his homescreen.  </p>
  
  <p>when user launches application again - it opens from existing instance,clears task and becomes root of it (because clearTaskOnLaunch="true") </p>