public void onExportFinished(ExportThread task) {
    if (task.isCancelled()) {
      if (finish_after) finish();
      return;
    }

    AlertDialog alertDialog = new AlertDialog.Builder(AdministrationFunctions.this).create();
    alertDialog.setTitle(R.string.email_export);
    alertDialog.setIcon(android.R.drawable.ic_menu_send);
    alertDialog.setButton2(
        getResources().getString(R.string.ok),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // setup the mail message
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
            emailIntent.setType("plain/text");
            // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
            // context.getString(R.string.debug_email).split(";"));
            String subject =
                "[" + getString(R.string.app_name) + "] " + getString(R.string.export_data);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
            // context.getString(R.string.debug_body));
            // has to be an ArrayList
            ArrayList<Uri> uris = new ArrayList<Uri>();
            // Find all files of interest to send
            try {
              File fileIn = new File(StorageUtils.getSharedStoragePath() + "/" + "export.csv");
              Uri u = Uri.fromFile(fileIn);
              uris.add(u);
              // Send it, if there are any files to send.
              emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
              startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            } catch (NullPointerException e) {
              Logger.logError(e);
              Toast.makeText(
                      AdministrationFunctions.this,
                      R.string.export_failed_sdcard,
                      Toast.LENGTH_LONG)
                  .show();
            }

            dialog.dismiss();
          }
        });
    alertDialog.setButton(
        getResources().getString(R.string.cancel),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // do nothing
            dialog.dismiss();
          }
        });

    alertDialog.setOnDismissListener(
        new OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface dialog) {
            if (finish_after) finish();
          }
        });

    if (!isFinishing()) {
      try {
        //
        // Catch errors resulting from 'back' being pressed multiple times so that the activity is
        // destroyed
        // before the dialog can be shown.
        // See http://code.google.com/p/android/issues/detail?id=3953
        //
        alertDialog.show();
      } catch (Exception e) {
        Logger.logError(e);
      }
    }
  }