GithubHelp home page GithubHelp logo

[BUG] Android "hardware" back button closes the app when app contains a tabbed page with a navigation page as root page for one of the tabs, Take 2 about prism HOT 4 OPEN

skha83 avatar skha83 commented on September 27, 2024 2
[BUG] Android "hardware" back button closes the app when app contains a tabbed page with a navigation page as root page for one of the tabs, Take 2

from prism.

Comments (4)

PauchardThomas avatar PauchardThomas commented on September 27, 2024

Same problem !

from prism.

dansiegel avatar dansiegel commented on September 27, 2024

fixed by #3148

from prism.

skha83 avatar skha83 commented on September 27, 2024

Hi @dansiegel while the recently introduced error of getting double back event has been fixed by #3148 the original problem of both the issue in scenario 2 of this issue and my original issue in #3095 still persist.
The problem was that the application would terminate when pressing the Android back button when standing on the root page of the navigation stack on a given tab page, instead of just putting the app into the background. This is at least my expected behavior,

The problem occur because a NavigationException.CannotPopApplicationMainPage occurs in

if (result.Exception is NavigationException { Message: NavigationException.CannotPopApplicationMainPage })
which I also already described in the original issue #3095 . This happens because it cannot pop the root page which makes sense. But instead of quitting the whole application it should just put it into background, which is the normal behavior for the apps I normally use. The underlying problem is probably in the call to navigationService.GoBackAsync() in this line
var result = await navigationService.GoBackAsync();
it should not throw an exception result but rather put the app into the background.

I know you are a busy man, but I hope this will get fixed at some point. For now I will stop creating new issues on the problem, as I don't want to pollute with new issues repeating myself.

from prism.

mdartu avatar mdartu commented on September 27, 2024

We are hitting this problem, in what I believe to be a slightly different flavour that is not covered in #3148:

We have a NavigationPage that contains a TabbedPage, with a button to navigate to another TabbedPage. When navigating back using the system back button, the app is sent to the background. When using the soft back button provided by NavigationPage, the navigation is handled as expected.
The structure is somewhat like this: navigate back from PrismNavigationPage <- SomeTabbedPage <- SomePage to PrismNavigationPage <- SomeOtherTabbedPage <- SomeOtherPage. When using the system back button, the initial back navigation is handled (correctly) from PrismNavigationPage.OnBackButtonPressed(): a breakpoint in MvvmHelpers.HandleNavigationPageGoBack() is hit and back navigation is handled there. However, the callback passed in android.OnBackPressed (PrismAppBuilder.cs) is also called. When this happens, window.CurrentPage is SomePage, window.CurrentPage.Parent is SomeTabbedPage and window.CurrentPage.Parent.Parent is PrismNavigationPage, so the code does not hit the check around line 84 and false is returned, likely telling the OS to put the window in the background.

The behaviour that I expect is that the soft back button behaves the same as the hardware back button. The hardware back button should put the app in the background (not stop the process) when the navigation stack is empty.

from prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.