button back event

0

I have an application that has a Login screen, it is the app's initial call. When logging in, the ActivityMain is called and the app follows its flow.

I would like to control the back button event of the android, I would like that when I click the back button I would not go back to the Login Activity. The back button of the android itself, not that of the actionbar. I've put the code below, but I do not think it's the best way to treat it.

@Override
public void onBackPressed() {
    Intent intent = new Intent(MainActivity.this,MainActivity.class);
    startActivity(intent);
}
    
asked by anonymous 19.04.2016 / 16:05

1 answer

0

Henry,

You have been asked to terminate the login activity after opening MainActivity.

Now, if you will allow me, this back button change is not good practice. The back button has the goal of always returning to the previous screen, while the up button (that is in the actionbar) has the goal of going to the screen screen of the current screen, that is, of climbing the hierarchy of the screens. Please read this document .

    
19.04.2016 / 17:59