title: Passing arguments to AsyncTask, and returning results
body: <p>I have an application that does some long calculations, and I would like to show a progress dialog while this is done. So far I have found that I could do this with threads/handlers, but didn't work, and then I found out about the <code>AsyncTask</code>. </p>
  
  <p>In my application I use maps with markers on it, and I have implemented the onTap function to call a method that I have defined. The method creates a dialog with Yes/No buttons, and I would like to call an <code>AsyncTask</code> if Yes is clicked. My question is how to pass an <code>ArrayList&lt;String&gt;</code> to the <code>AsyncTask</code> (and work with it there), and how to get back a new <code>ArrayList&lt;String&gt;</code> like a result from the <code>AsyncTask</code>?</p>
  
  <p>The code of the method looks like this:</p>
  
  <pre><code>String curloc = current.toString();
  String itemdesc = item.mDescription;
  
  ArrayList&lt;String&gt; passing = new ArrayList&lt;String&gt;();
  passing.add(itemdesc);
  passing.add(curloc);
  
  ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;();
  
  new calc_stanica().execute(passing,result);
  
  String minim = result.get(0);
  int min = Integer.parseInt(minim);
  
  String glons = result.get(1);
  String glats = result.get(2);
  
  double glon = Double.parseDouble(glons);
  double glat = Double.parseDouble(glats);
  
  GeoPoint g = new GeoPoint(glon, glat);
  String korisni_linii = result.get(3);
  </code></pre>
  
  <p>So, as you see, I would like to send the string array list "passing" to the <code>AsyncTask</code>, and to get the "result" string array list back from it. And the calc_stanica <code>AssycTask</code> class looks like this:</p>
  
  <pre><code>public class calc_stanica extends AsyncTask&lt;ArrayList&lt;String&gt;, Void, ArrayList&lt;String&gt;&gt; {
      ProgressDialog dialog;
  
      @Override
      protected void onPreExecute() {
          dialog = new ProgressDialog(baraj_mapa.this);
          dialog.setTitle("Calculating...");
          dialog.setMessage("Please wait...");
          dialog.setIndeterminate(true);
          dialog.show();
      }
  
      protected ArrayList&lt;String&gt; doInBackground(ArrayList&lt;String&gt;... passing) {
  
          //Some calculations...
  
          return something; //???
      }
  
      protected void onPostExecute(Void unused) {
          dialog.dismiss();
      }
  </code></pre>
  
  <p>So my question is how to get the elements of the "passing" array list in the <code>AsyncTask doInBackground</code> method (and use them there), and how to return an array list to use in the main method (the "result" array list)?</p>