title: Android find current fragment
body: <p>I have 4 java class that i use as fragments: `F1,F2,F3,F4.
  When i want to swich from one to other, i use this code:</p>
  
  <pre><code>android.app.FragmentManager FM = getFragmentManager();
          FragmentTransaction FT = FM.beginTransaction();
          F1 FP = new F1();
          FT.add(R.id.where, FP,"F1");
          FT.commit();
          FM.executePendingTransactions();
  </code></pre>
  
  <p>If i want to make possible to return from one of them to the previous, i add <code>addToBackStack(TAG)</code> as following:</p>
  
  <pre><code>android.app.FragmentManager FM = getFragmentManager();
          FragmentTransaction FT = FM.beginTransaction();
          F1 FP = new F1();
          FT.add(R.id.where, FP,"F1");
          FT.addToBackStack("F1");
          FT.commit();
          FM.executePendingTransactions();
  </code></pre>
  
  <p>I have only one activity that chages the current fragment displayed.
  I would get from it, the current fragment displayed. 
  I tried to write this, but <code>now</code> is always null.</p>
  
  <pre><code>Fragment now=getSupportFragmentManager().findFragmentByTag("F1");
  if(now!=null &amp;&amp; now.isVisible()) {
  //some code for the current fragment
  }
  </code></pre>