title: getActivity() is null inside AlertDialog of a fragment
body: <p>Why the <code>getActivity()</code> is returning null inside <code>AlertDialog</code> ?</p>
  
  <p><strong>This is the class -</strong></p>
  
  <pre><code>Class A extends Common{
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
          Button save = (Button) view.findViewById(R.id.save);
          save.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
          System.out.println("the activity outside dialog.."+getActivity());
  
          AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
          alert.setPositiveButton("Check acitivity", 
          new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, 
              int whichButton) {
              dialog.cancel();
              System.out.println("the activity inside dialog.."+getActivity());
              }
           });
        }
  }
  </code></pre>
  
  <p><strong>The Common class is extending fragment as -</strong></p>
  
  <pre><code>import android.support.v4.app.Fragment;
  Class Common extends Fragment
  {
    //Some code
  }
  </code></pre>
  
  <p><strong>And the output is -</strong></p>
  
  <pre><code>the activity outside dialog..com.testapp.main.MainActivity@42131080
  the activity inside dialog..null
  </code></pre>