Disable android back button on gaming app

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.

Upvotes: -5

Views: 792

Answers (2)

Boken
Boken

Reputation: 5362

Add to your Activity class EMPTY onBackPressed method:

In Kotlin:

override fun onBackPressed() {

}

In Java:

@Override
public void onBackPressed() {

}

Upvotes: 1

Basi
Basi

Reputation: 3158

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

like

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

Upvotes: 0

Related Questions