public void clearStack(){
  mPopInProgress=true;
  setAnimationEnabled(false);
  FragmentManager fragmentManager=getFragmentManager();
  int entryCount=fragmentManager.getBackStackEntryCount();
  Log.v(TAG,String.format("clearStack()... entries [%d]",entryCount));
  for (int i=0; i < entryCount; ++i) {
    try {
      fragmentManager.popBackStackImmediate();
    }
 catch (    Exception exc) {
      Log.e(TAG,"clearStack()",exc);
    }
  }
  findCurrentFragment();
  Log.v(TAG,"clearStack()... DONE");
  setAnimationEnabled(true);
  mPopInProgress=false;
}

public void clearStack ( ) { mPopInProgress = true ; setAnimationEnabled ( false ) ; FragmentManager fragmentManager = getFragmentManager ( ) ; int entryCount = fragmentManager . getBackStackEntryCount ( ) ; Log . v ( TAG , String . format ( "clearStack()... entries [%d]" , entryCount ) ) ; for ( int i = 0 ; i < entryCount ; ++ i ) { try { fragmentManager . popBackStackImmediate ( ) ; } catch ( Exception exc ) { Log . e ( TAG , "clearStack()" , exc ) ; } } findCurrentFragment ( ) ; Log . v ( TAG , "clearStack()... DONE" ) ; setAnimationEnabled ( true ) ; mPopInProgress = false ; }
clears fragments back stack removing all fragments from the hierarchy .
