Search code examples
c#androidxamarin.formsprismback-button

Xamarin.forms android Prism handle hardware back button


I am having issue while handling back button on android device. I want to handle navigation stack while user press hardware back button how I can achieve this?


Solution

  • You can override the OnBackButtonPressed() function

    protected override bool OnBackButtonPressed (){
        //Handle your navigation here
    }
    

    Details from the official docs

    Note: this will only work for Android, but that seems to be the only platform you are asking for. If you require a cross-platform solution, see this question.