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