How to make a function to when you click "Back" in Android
in Xamarin
, does the app return to the previous screen?
How to make a function to when you click "Back" in Android
in Xamarin
, does the app return to the previous screen?
Speaking about Xamarin.Forms for "Cross Platform Xamarin", you should use OnBackButtonPressed
. But remembering how it says in the documentation:
The event is generated when the hardware button 'back' is pressed. This event is not generated on iOS.
Just replace this event in your NavigationPage and you're ready to go:
protected override bool OnBackButtonPressed()
{
// A mágica acontece aqui
return true;
}
On any page, you can override this method
protected override bool OnBackButtonPressed()
{
return base.OnBackButtonPressed();
}