Skip to content

josco007/CHD.HWBackButtonManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CHD.HWBackButtonManager

If this project help you reduce time to develop, you can give me a cup of coffee :)

paypal

Singlenton util to handle the android hardware back button in a .NetStandard project

How to install:

You can install from the nuget manager in visual studio

nuget link: https://www.nuget.org/packages/CHD.HWBackButtonManager/#

Usage:

On your pcl project page:

protected override void OnAppearing()
{
    base.OnAppearing();

    bool OnBackButtonPressed()
    {
        return false; //false ignore backbutton
    }

    HWBackButtonManager.OnBackButtonPressedDelegate onBackButtonPressedDelegate = new HWBackButtonManager.OnBackButtonPressedDelegate(OnBackButtonPressed);

    HWBackButtonManager.Instance.SetHWBackButtonListener(onBackButtonPressedDelegate);
 

}



protected override void OnDisappearing()
{
    base.OnDisappearing();
    HWBackButtonManager.Instance.RemoveHWBackButtonListener(); // other pages allow backbutton
}

On your andriod MainActivity:

public override void OnBackPressed()
{


    if (!CHD.HWBackButtonManager.Instance.NotifyHWBackButtonPressed()){
        return;
    }

    base.OnBackPressed();
}

About

singlenton util to handle back button in a .NetStandard project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages