title: getActivity cannot resolve method from fragment
body: <p>I have to create an ArrayAdapter, but when I put getActivity() into the constructor it says <code>cannot resolve method getActivity()</code></p>
  
  <pre><code>        import java.io.BufferedReader;
          import java.io.IOException;
          import java.io.InputStreamReader;
          import java.net.ProtocolException;
          import java.net.URL;
          import java.util.ArrayList;
          import android.widget.ArrayAdapter;
          import java.net.HttpURLConnection;
          import java.lang.Void;
          import android.widget.ListView;
          import android.os.AsyncTask;
          import android.content.Context;
  
  
                  public class HttpURLConnectionExample extends AsyncTask&lt;ListView, Void, String&gt; {
  
                      public ListView myList = null;
  
                      public void sendGet(ListView lv){
                          myList = lv;
                          this.execute();
                          return;
                      }
  
                      @Override
                      protected String doInBackground(ListView... arg0) {
                          String url = "http://192.168.1.9";
                          URL obj = null;
                          try{
                              obj = new URL(url);}
                          catch(IOException e){}
                          HttpURLConnection con = null;
                          try{
                              con = (HttpURLConnection) obj.openConnection();}
                          catch(IOException e){}
  
                          //con.setRequestProperty("User-Agent", USER_AGENT);
                          try{
                              con.setRequestMethod("GET");}
                          catch(ProtocolException e){}
                          try{
                              con.connect();}
                          catch(IOException e){}
                          try{
                              int responseCode = con.getResponseCode();}
                          catch(IOException e){}
                          BufferedReader in = null;
                          try{
                              in = new BufferedReader(
                                      new InputStreamReader(con.getInputStream()));}
                          catch(IOException e){}
                          String inputLine;
                          StringBuffer response = new StringBuffer();
                          try{
                              while ((inputLine = in.readLine()) != null) {
                                  response.append(inputLine);
                              }}
                          catch(IOException e){}
                          try{
                              in.close();}
                          catch(IOException e){}
                          //print result
                          System.out.println(response.toString());
                          return response.toString();
                      }
  
                      @Override
                      protected void onPostExecute(String result) {
                          String strParts[] = result.split("@");
                          ArrayList&lt;dispencer&gt; listAr = new ArrayList&lt;dispencer&gt;();
                          for(int i=0; i&lt;strParts.length; i++){
                              listAr.add( new dispencer(strParts[i]) );
                          }
  
                          final ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_expandable_list_item_1);
  
                          for (int i = 0; i &lt; listAr.size(); ++i) {
                              adapter.add(listAr.get(i).toString());
                          }
                          myList.setAdapter(adapter);
                          return ;
                      }
  
              }
  </code></pre>
  
  <p>I read i had to use getActivity method since i'm in a fragment and not in context. 
  EDIT i coudn't extend my MainActivity Class because this class already extend asyncTask.</p>