I have fatal exception in the method onBackPressed(): on a null object reference. How to handle the exception correctly? My code:
@Override
public void onBackPressed() {
List fragments = getSupportFragmentManager().getFragments();
BaseExampleFragment currentFragment = (BaseExampleFragment) fragments.get(fragments.size() - 1);
if (fragments != null && !currentFragment.onActivityBackPress()) {
super.onBackPressed();
}
}