How to handle back button on android?

hi every one
I have problem in handling back button on Android device :roll_eyes:
when I press back button , game will be close and code don’t run :expressionless:
my code for handling back button :

        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN ,(event) => {
            console.log(event.keyCode);
            console.log(cc.macro.KEY.back );
            
            if (event.keyCode == cc.macro.KEY.back ) {
                this.label.string = "back button pressed"
            }

        } , this)

I use version 2.4

I believe there is an open topic about this already: Android back key not working? v3.2.x and 3.3.1

thank’s for reply I found a away with android studio

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.