How to track the back-button of Android devices?

76 views Asked by At

How is the proper way to catch the back button event in my CocosSharp game? Does it has to happen on the Android project or can it be done in the PCL core?

How is it done?

1

There are 1 answers

1
York Shen On

As @ADimaano said, you could implment it in PCL by override the OnBackButtonPressed method.

For example :

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    protected override bool OnBackButtonPressed()
    {
        //Do something
        return base.OnBackButtonPressed();
    }
}