title: Why can't i call a method to the parent activity from a fragment?
body: <p>I have a fragment where I wish to call a method from the FragmentActivity that contains this fragment. I defined a method in FragmentTabs(extends FragmentActivity) that sets the lastTab fragment on a specific event in the fragment.
  For some reason getActivity().SomeUserDefinedActivity() cannot be resolved.</p>
  
  <p>Here is the code explaining my problem :</p>
  
  <pre><code>@Override
  public void onActivityCreated(Bundle savedInstanceState)
  {
      super.onActivityCreated(savedInstanceState);
  
      testButton = (Button)getView().findViewById(R.id.button1);
      testButton.setOnClickListener(new OnClickListener()
      {
          @Override
          public void onClick(View v) 
          {
              Log.i("FragmentTest", "Button1 Clicked");
  
  
              TestFragment2 f2 = new TestFragment2();
              FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
              ft.replace(R.id.realtabcontent, f2);
              ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
              ft.addToBackStack(null);
              ft.commit();
              // This is where I want to call FragmentTabs method SetLastFragment, but I cannot access it.
              getActivity().SetLastFragment(f2);
  
          }
      });
  }
  </code></pre>
  
  <p>This is the method I wish to call in FragmentTabs:</p>
  
  <pre><code>    public void SetLastFragment(Fragment f)
  {
      mTabManager.SetLastTabFragment(f);
  }
  </code></pre>