title: FragmentTransaction replace not working
body: <p>I already searched for this issue on stackoverflow and found this two solutions:</p>
  
  <p><a href="https://stackoverflow.com/questions/5658675/replacing-a-fragment-with-another-fragment-inside-activity-group">Replacing a fragment with another fragment inside activity group</a><br>
  <a href="https://stackoverflow.com/questions/11619573/fragment-add-or-replace-not-working">Fragment add or replace not working</a></p>
  
  <p>But my code seems to be correct as you can check below, the comments on my code are in Portugues (Brazil):</p>
  
  <p>This is my class MenuItemReceiver (Yes, I use a BroadcastReceiver to show my fragments), this already work to show my fragment content but when I try to replace it, the old fragment stays and the new one just appear above the old one.</p>
  
  <pre><code>    public void onReceive(Context context, Intent intent) {
          //Fragment que será carregado, este fragment foi repassado pelo SlideMenuAdapter ao ter um item clicado
          Serializable serializableExtra = intent.getSerializableExtra(CustomFragment.CUSTOM_FRAGMENT);
          //Cast para CustomFragment uma vez que devemos recupera-lo como Serializable, poderia ter dado cast direto, mas decidi manter assim para melhor entendimento do código
          CustomFragment fragment =  (CustomFragment) serializableExtra;
          FragmentTransaction ft = slideMenuActivity.getSupportFragmentManager().beginTransaction();//Informa que estamos inicando uma transação nova
          ft.replace(R.id.dashboard,fragment);
          ft.addToBackStack(null);
          ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
          ft.commit();
          //Aplicamos as alterações permitindo que o estado do fragment seja perdido posteriormente, utilizamos o StateLoss para otimizar 
          //o gerenciamento de memória e garantir que nenhum fragment fique para traz porem sem possibilitado de ser "revisitado"
          slideMenuActivity.toggle();//Aqui simplesmente estamos escondendo o menu
      }
  </code></pre>
  
  <p>I have tried also with this code and have no difference:</p>
  
  <pre><code>    public void onReceive(Context context, Intent intent) {
          Serializable serializableExtra = intent.getSerializableExtra(CustomFragment.CUSTOM_FRAGMENT);
          CustomFragment fragment =  (CustomFragment) serializableExtra;
          Fragment oldFragment = slideMenuActivity.getSupportFragmentManager().findFragmentById(R.id.dashboard);
          FragmentTransaction ft;
          if(oldFragment!=null){
              ft = slideMenuActivity.getSupportFragmentManager().beginTransaction();
              ft.remove(oldFragment);
              ft.commit();
          }
          ft = slideMenuActivity.getSupportFragmentManager().beginTransaction();ft.add(R.id.dashboard,fragment);
          ft.addToBackStack(null);
          ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
          ft.commit();
          slideMenuActivity.toggle();
      }
  </code></pre>
  
  <p>And here you can see my dashboard layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/dashboard"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/white" &gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>