title: Back button restores unwanted previous page in Android on Xamarin
body: <p>I am developing an app that starts with a login page, called <code>LoginPage</code>.</p>
  
  <p>Once logged in a different page is viewed, called <code>UserPage</code>.</p>
  
  <p>Once <code>LoginPage</code> has been popped and <code>UserPage</code> has been pushed, I press the back button on the Android device, which takes me to the home screen.</p>
  
  <p>Once at the home screen I reopen the app from the app manager (the little square button at the lower right side of the device) and the <code>LoginPage</code> reappears.</p>
  
  <p>Why is that?</p>
  
  <p>My code to pop the <code>LoginScreen</code> is as following:</p>
  
  <pre><code>Application.Current.MainPage = new UserPage();
  await Navigation.PopToRootAsync(true);
  </code></pre>
  
  <p><strong>EDIT 1</strong>
  Main app method</p>
  
  <pre><code>    public App()
      {
          InitializeComponent();
  
          var navPage = new NavigationPage(new LoginPage());
          NavigationPage.SetHasNavigationBar(navPage.CurrentPage, false);
  
          MainPage = navPage;
      }
  </code></pre>