You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an app contains a tabbed page where one of the tabs contains a navigation page as the root page and two page segments, when this tab is active and pressing the Android hardware back button twice it closes the app when it was expected the app would be put into background.
Steps to Reproduce
Clone this repository.
Open the E2E example solution for MAUI.
Uncomment the tabbedpage example code in MauiProgram.cs or paste in the following lines as the commented code contain a small error:
.CreateWindow(nav => nav.CreateBuilder().AddTabbedSegment(page => page.CreateTab("ViewC").CreateTab(t => t.AddNavigationPage().AddSegment("ViewA",s => s.AddParameter("message","Hello Tab - ViewA")).AddSegment("ViewB",s => s.AddParameter("message","Hello Tab - ViewB"))).SelectedTab("NavigationPage|ViewB")).AddParameter("message_global","This is a Global Message").NavigateAsync())
Start the app on a real phone or Android simulator.
Make sure you are on the tab containing the NavigationPage and the View B and View A pages.
Press the hardware back button twice, to first navigate from View B -> View A and then to put the app into background
Expected result: The app goes to the background and is still running.
Actual result: The app terminates when pressing the back button the last time.
I debugged the problem and it originates from the GoBackInternalAsync in the PageNavigationService
throwing a NavigationException with NavigationException.CannotPopApplicationMainPage when it recursively tries to find out if the current page is a root page. This then causes the application to quit in the MvvmHelpers class in the HandleNavigationPageGoBack method
Hi @dansiegel, I have tried the navigation changes introduced in version 9.0.436-pre which should resolve this issue. I'm still having problems getting the navigation to work the way I expect it to work.
I have created a fork on the current Prism main and simplified my example so it only contain one tabbed page with a navigation page and two segments here https://github.com/skha83/Prism
Deploy and launch the PrismMauiDemo app from my repository on an Android phone.
The app is launched with ViewB page on top and ViewA and NavigationPage below.
Press the hardware back button.
Expected result:
The app will navigate from ViewB -> ViewA but stay in foreground so ViewA is visible.
Actual result:
The app navigates to ViewA but immediately backgrounds the app. When the app is opened again ViewA is the current window. But the app is not terminated.
Scenario 2.
Deploy and launch the PrismMauiDemo app from my repository on an Android phone.
The app is launched with ViewB page on top and ViewA and NavigationPage below.
Press the software navigate back button on the top left of the app, so it navigates back to ViewA.
When ViewA is visible press the hardware back button.
Expected result:
The app will be backgrounded but not completely terminated.
Actual result:
The app gets completely terminated and needs to be relaunched and is started from scratch.
The behavior in scenario 1 is different from before the new changes. Previously it would correctly navigate from ViewB -> ViewA and not background the app if the hardware back button is only pressed once.
Scenario 2 is working in the same way as before the recent changes.
I don't know if I shall create a new issue or this issue can get reopened?
Description
When an app contains a tabbed page where one of the tabs contains a navigation page as the root page and two page segments, when this tab is active and pressing the Android hardware back button twice it closes the app when it was expected the app would be put into background.
Steps to Reproduce
Expected result: The app goes to the background and is still running.
Actual result: The app terminates when pressing the back button the last time.
I debugged the problem and it originates from the GoBackInternalAsync in the PageNavigationService
Prism/src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
Line 159 in 2338a75
Prism/src/Maui/Prism.Maui/Common/MvvmHelpers.cs
Line 304 in 2338a75
This has been tested on the latest main branch and nuget package 9.0.422-pre from the sponsor connect feed.
Platform with bug
.NET MAUI
Affected platforms
Android
Did you find any workaround?
No workaround.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: