Posted on Leave a comment

Override hardware back button Xamarin.Forms

Some phones support the hardware back button and this may disturb the designed navigation experience that has been implemented in the application. You can override this behavior on Android (iOS does not support a hardware back button) with the following code that has to be placed in the MainActivity.cs of your Android root folder after onCreate method.

 public override void OnBackPressed()
        {
           return;
        }

The result should look like below. After this action the hardware back button will have no effect and the whole navigation can be performed through the application.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.