title: Setting and getting fragment by tag always return null
body: <p>So am trying to make 2 fragments communicate over their parent activity. 
  I implement interface and callback functions like this : </p>
  
  <pre><code>public class FormFragment extends Fragment {
  
      private EditText mStudentTextField;
      private EditText mStudentIndexField;
      private Button mSubmit;
      private String mStudentName;
      private int mStudentIndex;
      SendData sd;
  
      interface SendData {
  
          public void send(String msg);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.form_input, container, false);
  
          mStudentTextField = (EditText) view.findViewById(R.id.input_name);
          mStudentIndexField = (EditText) view.findViewById(R.id.input_index);
          mSubmit = (Button) view.findViewById(R.id.submit_button);
  
          mSubmit.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  mStudentName = mStudentTextField.getText().toString();
                  // mStudentIndex =
                  // Integer.parseInt(mStudentIndexField.toString());
  
                  sd.send(mStudentName);
                  HomeFragment homeFragment = new HomeFragment();
                  FragmentTransaction ft = getFragmentManager()
                          .beginTransaction();
                  ft.replace(R.id.formFragment_Container, homeFragment,
                          "HOME_FRAGMENT").commit();
              }
          });
  
          return view;
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          try {
              sd = (SendData) activity;
          } catch (ClassCastException c) {
  
              throw new ClassCastException(activity.toString()
                      + "Must implement send() method");
          }
      }
  }
  </code></pre>
  
  <p>This is like a middle ground. FormFragments gets attached 1st in MainActivity 
     and gets called first. Next, I take values from EditText and on button click  I call callback function that gets 2 values (name and index) to MainActivity. So getting data from FormFragment to Activity works. </p>
  
  <p>Here's my HomeFragment that should get data from MainActivity and display them on proper TextFields.</p>
  
  <p>HomeFragment controller : </p>
  
  <pre><code>public class HomeFragment extends Fragment {
  
      private TextView mName;
      private TextView mIndex;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.home, container, false);
  
          mName = (TextView) view.findViewById(R.id.student_name);
          mIndex = (TextView) view.findViewById(R.id.student_index);
  
          return view;
  
      }
  
      public void getData(String msg) {
  
          mName.setText(msg);
      }
  }
  </code></pre>
  
  <p>So, you see. It's simple. Just get data from args and do something with it.
       Now, in MainActivity, I get a problem I can't seem to solve despite surfing Stack Overflow and reading documentation on android developers and github.</p>
  
  <p>Take a look at my MainActivity : </p>
  
  <pre><code>public class MainActivity extends Activity implements FormFragment.SendData {
  
      private String test;
      HomeFragment hf;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          FragmentManager fm = getFragmentManager();
          FragmentTransaction ft = fm.beginTransaction();
          FormFragment formFragment = new FormFragment();
  
          ft.add(R.id.formFragment_Container, formFragment, "FORM_FRAGMENT")
                  .addToBackStack(null).commit();
  
          hf = (HomeFragment) getFragmentManager().findFragmentByTag(
                  "HOME_FRAGMENT"); // get a reference to a home fragment
  
      }
  
      @Override
      public void send(String msg) {
  
          hf.getData(msg);
      }
  }
  </code></pre>
  
  <p>Problem is that hf is null reference , so when I call getData() it crashes, obviously. I believe that I've properly set TAG names for both fragments, for first fragment in add(), and for second in replace(). What could be the reason behind such behavior. Thanks     </p>