Avoid going back to the previous screen

0

I'm doing a game in Android Studio and at a certain moment I'm going to another screen. How can I say "block" that new screen to avoid going back? Thanks!

    
asked by Sergio AG 10.03.2018 в 18:37
source

1 answer

1

If you want to avoid returning to the previous screen by pressing the back button, you overload the event onBackPressed () of your Activity .

@Override
public void onBackPressed(){
  //En caso de querer permitir volver atrás usa esta llamada:
  super.onBackPressed();
}

To go back without having to press the button you can use finish () .

    
answered by 10.03.2018 / 19:42
source