Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

The OnAppearing() issue with Navigation.PushAsync() #2716

Closed
Billycool1020 opened this issue May 15, 2018 · 3 comments
Closed

The OnAppearing() issue with Navigation.PushAsync() #2716

Billycool1020 opened this issue May 15, 2018 · 3 comments
Labels
e/5 🕔 5 help wanted We welcome community contributions to any issue, but these might be a good place to start! inactive Issue is older than 6 months and needs to be retested p/Android t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@Billycool1020
Copy link

Description

In main page use a button call Navigation.PushAsync(new Page1()) to open Page1. The OnAppearing() in Page1 fired again immediately if I call the Device.OpenUri(new Uri("https://github.com/")) in the OnAppearing(). But if I set a breakpoint or set Task.Delay(500) before the Device.OpenUri(), second OnAppearing() will not fired until I get back from the browser. The similiar issue also happens when call Navigation.PushAsync() in the OnAppearing().

Steps to Reproduce

  1. The App.cs:
		public App ()
		{
			InitializeComponent();
			MainPage = new NavigationPage(new MainPage());
		}

  1. MainPage
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"           
             x:Class="App1.MainPage">
    <StackLayout>
        <!-- Place new controls here -->
        <Button Text="Page 1" x:Name="button" Clicked="button_Clicked"/>
    </StackLayout>
</ContentPage>
	public partial class MainPage : ContentPage
	{
		public MainPage()
		{
			InitializeComponent();
		}
                private void button_Clicked(object sender, EventArgs e)
                {
                    Navigation.PushAsync(new Page1());
                }
       }
  1. Page1
	public partial class Page1 : ContentPage
	{
		public Page1 ()
		{
			InitializeComponent ();
       		 }
      		 protected override  void OnAppearing()
    		 {   
                        base.OnAppearing();
                        Device.OpenUri(new Uri("https://github.com/"));
                 }
         }

Expected Behavior

OnAppearing() fired and open one tab in the browser.

Actual Behavior

OnAppearing() fired twice and open two tabs in the browser. If I set a breakpoint or set Task.Delay(500) before the Device.OpenUri();, second OnAppearing() will not fired immediately .

Basic Information

  • IDE: Visual Studio Enterprise 2017 15.7.1
  • Platform Target Frameworks:
    • Android: 8.1
@pauldipietro
Copy link
Contributor

The described behavior appears to occur as of the 3.1-pre on an 8.1 emulator.

@VahidShir
Copy link

I have this problem in Xamarin.Forms "2.5.1.527436" and on both emulator and device.

@samhouts samhouts added the e/5 🕔 5 label Jul 30, 2018
@samhouts samhouts added the inactive Issue is older than 6 months and needs to be retested label Dec 20, 2018
@samhouts samhouts added help-wanted up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! help wanted We welcome community contributions to any issue, but these might be a good place to start! and removed help-wanted labels Jun 28, 2019
@PureWeen
Copy link
Contributor

Consolidating OnAppearing issues here
#6919

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e/5 🕔 5 help wanted We welcome community contributions to any issue, but these might be a good place to start! inactive Issue is older than 6 months and needs to be retested p/Android t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
None yet
Development

No branches or pull requests

5 participants