0

When the first back is hit, it goes back to 3 which is MainActivity. The second back goes to 1 which is MainActivity again.

That is, MainActivity is repeated twice, which is not interesting!

I want exit the app wherever there was MainActivity and back pressed. enter image description here

PCcloob.Ir
  • 59
  • 10

1 Answers1

0

use this code on which activity you want to close app on back button pressed

@Override
public void onBackPressed() {
    finishAffinity();
}
Taha Gorme
  • 456
  • 1
  • 12