title: getActivity after onAttach android
body: <p>I am trying to get the activity in a fragment as I keep getting a <code>null pointer exception</code> on my <code>getActivity.finish()</code>.</p>
  
  <p>I am trying to achieve this with the below:</p>
  
  <pre><code>@Override
  public void onAttach(Context context) {
      super.onAttach(activity);
      mContext = context;
  }
  
  @Override
  public void onDetach() {
      super.onDetach();
      mContext = null;
  }
  </code></pre>
  
  <p>In <code>super.onAttach(activity)</code> the <code>activity</code> word comes up red with the error: <code>cannot resolve symbol activity</code></p>
  
  <p>So do I need to set this equal too: <code>Activity activity = RepairActivity repairActivity</code> or something similar?</p>
  
  <p>And once set how would I call the <code>getActivity.finish()</code>? would this automatically be picked up by after the <code>onAttach()</code>?</p>
  
  <p>I am calling the activity like this:</p>
  
  <pre><code>android.app.FragmentManager fragmentManager = getFragmentManager();
  
  RepairFragment newFragment = new RepairFragment();
  
  newFragment.device = device;
  fragmentManager.beginTransaction()
      .replace(R.id.content_frame, newFragment)
      .commit();
  </code></pre>
  
  <p>Help appreciated</p>