title: How to avoid adding same fragment to stack
body: <p>I need some help. em adding fragment to activity this way. problem is on each call of openFragment it create fragment and add. which is obvious. Question: what modification i do, so it can add fragment only once. on the next call with same fragment tag it will do nothing. </p>
  
  <p>case: press button first time it add fragment and shows. i press again same button it response nothing. </p>
  
  <pre><code>public static void openFragment(Activity activity, Fragment fragment) {
  
      FragmentManager fragmentManager = ((ActionBarActivity) activity)
              .getSupportFragmentManager();
          FragmentTransaction ftx = fragmentManager.beginTransaction();
          ftx.addToBackStack(fragment.getClass().getSimpleName());
          ftx.setCustomAnimations(R.anim.slide_in_right,
                  R.anim.slide_out_left, R.anim.slide_in_left,
                  R.anim.slide_out_right);
          ftx.add(R.id.main_content, fragment);
          ftx.commit();
  }
  </code></pre>