title: Get current activity from fragment
body: <p>I have this class for sending email with android</p>
  
  <pre><code>    public class SendMailTask extends AsyncTask {
  
      private ProgressDialog statusDialog;
      private Activity sendMailActivity;
  
      public SendMailTask(Activity activity) {
          sendMailActivity = activity;
  
      }
  
      protected void onPreExecute() {
          statusDialog = new ProgressDialog(sendMailActivity);
          statusDialog.setMessage("Getting ready...");
          statusDialog.setIndeterminate(false);
          statusDialog.setCancelable(false);
          statusDialog.show();
      }
  
      @Override
      protected Object doInBackground(Object... args) {
          try {
              Log.i("SendMailTask", "About to instantiate GMail...");
              publishProgress("Processing input....");
              GMail androidEmail = new GMail(args[0].toString(),
                      args[1].toString(), (List) args[2], args[3].toString(),
                      args[4].toString());
              publishProgress("Preparing mail message....");
              androidEmail.createEmailMessage();
              publishProgress("Invio email in corso, sarai ricontattato da un nostro operatore per la conferma");
              androidEmail.sendEmail();
              publishProgress("Email Sent.");
              Log.i("SendMailTask", "Mail Sent.");
          } catch (Exception e) {
              publishProgress(e.getMessage());
              Log.e("SendMailTask", e.getMessage(), e);
          }
          return null;
      }
  
      @Override
      public void onProgressUpdate(Object... values) {
          statusDialog.setMessage(values[0].toString());
  
      }
  
      @Override
      public void onPostExecute(Object result) {
          statusDialog.dismiss();
      }
  }
  </code></pre>
  
  <p>Without using fragments i use the following code in the MainActivity  to send a mail</p>
  
  <pre><code>new SendMailTask(MainActivity.this).execute(fromEmail,
                     fromPassword, toEmailList, emailSubject, emailBody);
  </code></pre>
  
  <p>But now i need to use Fragment and i get an error at this point:
  "MainActivity.this its not an enclosing class"</p>
  
  <p>how can i solve this error?</p>
  
  <p>P.S.: Sorry for my bad english :D</p>