Disable android back button on gaming app

765 views Asked by At

When I try to add back button removal code, it gives error.

I created a game with buildbox, it's a drag and drop, and exported it to the Android Studio. I want to disable the android back button. Please, I need help on how to go about this.

2

There are 2 answers

0
Boken On

Add to your Activity class EMPTY onBackPressed method:

In Kotlin:

override fun onBackPressed() {

}

In Java:

@Override
public void onBackPressed() {

}
0
Basi On

override onBackPressed() method also remove super.onBackPressed()

like

    @Override
    public void onBackPressed() {
        // super.onBackPressed();
    }