Some devices such as Android and Windows Phone have a hardware or operating system "back" button. When it's pressed, the Nav.HardwareBack event gets fired. You can handle this static event for any custom handling. By default, Zebble will take the user back to the previous page in the Navigation Stack.
Example:
{
public override async Task Run()
{
....
Nav.HardwareBack.Handle()
}
async Task OnHardwareBackPressed(System.ComponentModel.CancelEventArgs args)
{
if (Nav.Stack.Any()) return; // Allow the normal behaviour
if (!await Alert.Confirm("Do you want to close the app?"))
args.Cancel = true; // Setting Cancel to true will prevent the standard system behaviour
}
}
You can actually test the button in the UWP version.
When the user is looking at a page while there is no previous page in the navigation stack, if she then presses the back button nothing will happen.
In that scenario, if you want the application to be minimised to show the Android home page, then you can achieve that behaviour by setting the following in your Config.xml file.