title: Is it possible to pass a fragment in a constructor?
body: <p>I am trying to pass my Fragment to an ASyncTask class so that I can update a widget or two in the fragment once the task completes. Here's what I'm dealing with:</p>
  
  <pre><code>public class LoginFragment extends Fragment {
  
      Button loginButton;
      TextView loginErrorMsg;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          return inflater.inflate(R.layout.loginfragment, container, false);
      }
  
      public OnClickListener loginListener = new OnClickListener() {
          @Override
          public void onClick(View v) {
              Log.v("LoginF", "onclick");
              ProgressDialog progressDialog = new ProgressDialog(getActivity());
              progressDialog.setMessage("Logging in...");
              LoginTask loginTask = new LoginTask((Polling) getActivity(), progressDialog);
              loginTask.execute();
          }
      };
  </code></pre>
  
  <p>And the LoginTask:</p>
  
  <pre><code>public class LoginTask extends AsyncTask&lt;String, Void, Integer&gt; {
  
  private ProgressDialog progressDialog;
  private Polling activity;
  private int id = -1;
  private JSONParser jsonParser;
  private static String loginURL = "http://davidjkelley.net/android_api/";
  private static String registerURL = "http://davidjkelley.net/android_api/";
  private static String KEY_SUCCESS = "success";
  private static String KEY_ERROR = "error";
  private static String KEY_ERROR_MSG = "error_msg";
  private static String KEY_UID = "uid";
  private static String KEY_NAME = "name";
  private static String KEY_EMAIL = "email";
  private static String KEY_CREATED_AT = "created_at";
  TextView loginErrorMsg = (EditText)activity.findViewById(R.id.loginErrorMsg);
  EditText userName = (EditText)activity.findViewById(R.id.emailEditText);
  EditText passwordEdit = (EditText)activity.findViewById(R.id.passEditText);
  
  public LoginTask(Polling activity, ProgressDialog progressDialog)
  {
      this.activity = activity;
      this.progressDialog = progressDialog;
  }
  </code></pre>
  
  <p>So I would like to add a third parameter to the constructor of LoginTask, essentially an instance of my LoginFragment. My goal is to update either a TextView or put up a Toast on the screen to clarify whether login succeeds or fails: as right now, the user has no way of telling how the login proceeded. Ideas?</p>