@Override public void onBackPressed() { FragmentManager fm = getSupportFragmentManager(); for(int i = 0; i < fm.getBackStackEntryCount(); ++i) { fm.popBackStack(); } } 

You see, here I have onBackPressed and is used to go back in fragments. And I need when the fragments run out showed an exit message. But I do not do anything, that is, it does not even exit the application.

How to solve a problem?

  • finish(); have you tried? - Silento

1 answer 1

You do not call the initial implementation of the onBackPressed() method. If I read your thoughts correctly, then you need to check whether fragments remain in the FragmentManager and if only one remains, then call super.onBackPressed()

  • Thanks, I did not notice, it turned out to be turned out! - DevOma 2:49 pm