title: How do I get the currently displayed fragment?
body: <p>I am playing with fragments in Android.</p>
  
  <p>I know I can change a fragment by using the following code:</p>
  
  <pre><code>FragmentManager fragMgr = getSupportFragmentManager();
  FragmentTransaction fragTrans = fragMgr.beginTransaction();
  
  MyFragment myFragment = new MyFragment(); //my custom fragment
  
  fragTrans.replace(android.R.id.content, myFragment);
  fragTrans.addToBackStack(null);
  fragTrans.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
  fragTrans.commit();
  </code></pre>
  
  <p>My question is, in a Java file, how can I get the currently displayed Fragment instance?</p>