OnApperaing and OnDisappearing called differently from OnPause -> OnResume (Android)

MAHolstMAHolst ✭✭USUniversity ✭✭

Hi all

I have an app where I use one navigation page, which i push and pop pages from.
Pushing a new page on top of the stack calls OnDisappearing on the top most page, and OnAppearing on the new page.
If I pop a page, OnDissapearing is called on the top most page, followed by OnAppearing on the page which is now the top most page.
Every thing is good.

However, if I have three pages pushed to the stack and I send the app to the background, the cycle differs.
Opening the app again from the task list, makes all three pages call OnAppearing, and none of them call OnDisappearing.

Is this intentional?
I would have guessed that only the top most page would call OnAppearing, and follow the pattern as described above. In that way all pages will call OnAppearing when the user can actually see the page.

As mentioned in the title, this is only tested on Android.

Best regards
Morten

Tagged:

Best Answer

Answers

  • ahmadmadiahmadmadi ✭✭✭ USMember ✭✭✭

    Hi there, I never did your test , but it is an interesting case and i have a question. Once the app coming back from the background, are you sure that all the three pages are called once only ? maybe the one that is on top get to call "OnAppearing" twice ...
    What about in case of having only two pages ? would both of them call "OnAppearing" too when the app is back from the background ?

  • MAHolstMAHolst ✭✭ USUniversity ✭✭
    edited October 2016

    Thanks for you response.

    Each page in the stack calls the OnAppearing excatly once.
    The number three was only an example, so the same goes for n pages.

  • AdrianKnightAdrianKnight ✭✭✭✭ USMember ✭✭✭✭
    Accepted Answer

    @MAHolst I fixed this issue. You should update to the latest pre-release. https://github.com/xamarin/Xamarin.Forms/pull/342

    There is also a platform specific feature now that lets you disable calling onappearing / ondisappearing on pause/resume. This is how iOS works as far as I know.

    https://github.com/xamarin/Xamarin.Forms/pull/450

  • AdrianKnightAdrianKnight ✭✭✭✭ USMember ✭✭✭✭

    Actually I'm not sure if it's in the latest. Maybe the next release will include it.

  • MAHolstMAHolst ✭✭ USUniversity ✭✭

    That is great news. I will be looking out for that fix.
    Thanks.

    Do you know when the next release will be out?

  • AdrianKnightAdrianKnight ✭✭✭✭ USMember ✭✭✭✭

    @MAHolst No idea. Unfortunately, they are slow on releasing new nugets. I've had to wait as much as 2 months :(

  • MAHolstMAHolst ✭✭ USUniversity ✭✭

    Ok.
    I will try to be patient.

Sign In or Register to comment.