@Override
 protected void onDestroy() {
   if (mInstanceUploaderTask != null) {
     mInstanceUploaderTask.setUploaderListener(null);
   }
   super.onDestroy();
 }
 @Override
 protected void onResume() {
   if (mInstanceUploaderTask != null) {
     mInstanceUploaderTask.setUploaderListener(this);
   }
   super.onResume();
 }
 @Override
 protected void onResume() {
   Log.i(t, "onResume: Resuming upload of " + mInstancesToSend.length + " instances!");
   if (mInstanceUploaderTask != null) {
     mInstanceUploaderTask.setUploaderListener(this);
   }
   if (mAlertShowing) {
     createAlertDialog(mAlertMsg);
   }
   super.onResume();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(t, "onCreate: " + ((savedInstanceState == null) ? "creating" : "re-initializing"));

    mAlertMsg = getString(R.string.please_wait);
    mAlertShowing = false;

    mUploadedInstances = new HashMap<String, String>();

    setTitle(getString(R.string.app_name) + " > " + getString(R.string.send_data));

    // get any simple saved state...
    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(ALERT_MSG)) {
        mAlertMsg = savedInstanceState.getString(ALERT_MSG);
      }
      if (savedInstanceState.containsKey(ALERT_SHOWING)) {
        mAlertShowing = savedInstanceState.getBoolean(ALERT_SHOWING, false);
      }

      mUrl = savedInstanceState.getString(AUTH_URI);
    }

    // and if we are resuming, use the TO_SEND list of not-yet-sent submissions
    // Otherwise, construct the list from the incoming intent value
    long[] selectedInstanceIDs = null;
    if (savedInstanceState != null && savedInstanceState.containsKey(TO_SEND)) {
      selectedInstanceIDs = savedInstanceState.getLongArray(TO_SEND);
    } else {
      // get instances to upload...
      Intent intent = getIntent();
      selectedInstanceIDs = intent.getLongArrayExtra(FormEntryActivity.KEY_INSTANCES);
    }

    mInstancesToSend = new Long[(selectedInstanceIDs == null) ? 0 : selectedInstanceIDs.length];
    if (selectedInstanceIDs != null) {
      for (int i = 0; i < selectedInstanceIDs.length; ++i) {
        mInstancesToSend[i] = selectedInstanceIDs[i];
      }
    }

    // at this point, we don't expect this to be empty...
    if (mInstancesToSend.length == 0) {
      Log.e(t, "onCreate: No instances to upload!");
      // drop through -- everything will process through OK
    } else {
      Log.i(t, "onCreate: Beginning upload of " + mInstancesToSend.length + " instances!");
    }

    // get the task if we've changed orientations. If it's null it's a new upload.
    mInstanceUploaderTask = (InstanceUploaderTask) getLastNonConfigurationInstance();
    if (mInstanceUploaderTask == null) {
      // setup dialog and upload task
      showDialog(PROGRESS_DIALOG);
      mInstanceUploaderTask = new InstanceUploaderTask();

      // register this activity with the new uploader task
      mInstanceUploaderTask.setUploaderListener(InstanceUploaderActivity.this);

      mInstanceUploaderTask.execute(mInstancesToSend);
    }
  }