title: fragment back to the end , the screen is white
body: <p>I have a <code>MainActivity</code>, it has a lots of <code>Fragment</code> under it.</p>
  
  <p>I set the return mechanism <code>transaction.addToBackStack(null);</code></p>
  
  <p>The function like this:</p>
  
  <pre><code>public void switchFragment(Fragment fragment) {
      FragmentManager manager = getSupportFragmentManager();
      FragmentTransaction transaction = manager.beginTransaction();
      transaction.replace(R.id.mainFrame, fragment, null);
      transaction.addToBackStack(null);
      transaction.commit();
  }
  </code></pre>
  
  <p>My issue is when I click the back button to the end, the <code>FrameLayout</code> is white
  <a href="https://i.stack.imgur.com/tktLa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tktLa.png" alt="white screen"></a></p>
  
  <p>I tried to add  </p>
  
  <pre><code>public boolean onKeyDown(int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_BACK) {    
          if (mainFrame==null)
              return super.onKeyDown(keyCode, event);
      }
  }
  </code></pre>
  
  <p>It's not working. How do I avoid this white screen when I call back the <code>Fragment</code> to the end ? Any help would be great! </p>