Created
November 19, 2014 09:32
-
-
Save devrath/e88cc70df57b498e58cc to your computer and use it in GitHub Desktop.
This is used to check onBackpressed if only one fragment is found using backstack count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Checking the backstack works perfectly | |
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) | |
{ | |
if (keyCode == KeyEvent.KEYCODE_BACK) | |
{ | |
if (getFragmentManager().getBackStackEntryCount() == 1) | |
{ | |
// DO something here since there is only one fragment left | |
// Popping a dialog asking to quit the application | |
return false; | |
} | |
} | |
return super.onKeyDown(keyCode, event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment