title: i have a floating button in main activity.i want to clear all fragments and return to Main Activity
body: <p>i have a floating button in main activity.i want to clear all fragments and return to Main Activity.my code is working when i am in Fragment A it returns on activity but but from Fragment B it returns to Fragment A not in Main Activity..plz guide me.
  My floating button Code is here</p>
  
  <pre><code>FloatingActionButton bt_home = (FloatingActionButton) findViewById(R.id.home);
      bt_home.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              FragmentManager fm = getFragmentManager();
              Fragment fragment = fm.findFragmentById(R.id.myFrame);
              if (fragment != null) {
  
                  fm.beginTransaction().remove(fragment).addToBackStack(null).commit();
              }
     //                getFragmentManager().beginTransaction().remove(getFragmentManager().findFragmentById(R.id.myFrame)).commit();
          }
      });
  </code></pre>