Side Menu Android Hardware Back Button

I have a minor issue on Android with the hardware back button on my app’s initial view while the side menu is open. I can get the side menu to close if you hit the back button while it is open but my app also exists after it closes. Is there a way to prevent this? Here is a snippet of what I’m trying to do that almost works -

.controller('Home', function($scope, $ionicSideMenuDelegate, $ionicPlatform) {
    $ionicPlatform.onHardwareBackButton(function() {
        if ($ionicSideMenuDelegate.isOpenLeft()) {
            $ionicSideMenuDelegate.toggleLeft();
        }
    });    
});

I have tried return false and preventDefault() in the back button event… no luck though, my app still exits after the side menu closes :~(

Thank you for all the amazing work on Ionic.

How about making the side menu close on Android when the hardware back button is pressed? Most native Android app’s do this when a side menu is open.

This would be similar to this feature below that was added in beta 1.0.0-beta.3

$ionicPopup: on android, make back button close popup (b87bcb30, closes #1222)

Once again thanks for all the work on Ionic.

If you want, you can make and issue/feature request for this. Sounds like a good feature to have.

1 Like

Thank you. I added a feature request to the repo.