How to pass parameter to Android AsyncTask
<p>My question is how to pass parameter to AsyncTask dynamically. How I do this?</p>

<pre><code> public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.daily_download);

    SharedPreferences myPrefs = this.getSharedPreferences("myLogedPrefs",MODE_WORLD_READABLE);
    strBusinessUnit = myPrefs.getString("BusinessUnit", "");
    strExecutive = myPrefs.getString("Executive", "");
    strTerritoryCode = myPrefs.getString("TerritoryCode", "");

    tableListGrid = (GridView)findViewById(R.id.dailydownloadgrid);
    tableListGrid.setAdapter(new TableListImageAdapter(this));
    tableListGrid.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position,long id) {
            if (position == 0) {
                dailyDownTable = "LoadTarget";
                jsonFilter = "Target1";
                new DailyDownldAsyncTask().execute();
            }
        }
    });
}



    public class DailyDownldAsyncTask extends AsyncTask&lt;Void, Integer, Void&gt; {
        // private final ProgressDialog dialog = new ProgressDialog(DailyDownloadActivity.this);
         int myProgress;

        @Override
        protected void onPostExecute(Void result) {

            //if (this.dialog.isShowing()) {
            //  this.dialog.dismiss();
            //}
            //Toast.makeText(DailyDownloadActivity.this,"Download successfully",Toast.LENGTH_SHORT).show();

        }

      @Override
      protected void onPreExecute() {

         // this.dialog.setMessage("Downloading Table Data.......");
         // this.dialog.show();
         // myProgress = 0;
      }

      @Override
      protected Void doInBackground(Void... params) {
          new DownlaodTableActivity().loadDailyDownloadData(dailyDownTable,jsonFilter,strBusinessUnit, strBusinessUnit,strTerritoryCode);
       return null;
      }

      @Override
      protected void onProgressUpdate(Integer... values) {
         // dialog.setProgress(values[0]);
      }
 }
</code></pre>

<p>I commented 'ProgressDialog ' &amp; run the code also I got error
Here <code>loadDailyDownloadDatadailyDownTable,jsonFilter,strBusinessUnit, strBusinessUnit,strTerritoryCode)</code> method i want to pass parameter.</p>

<p>When I run this code I got error :</p>

<pre><code>     08-19 09:22:15.521: ERROR/AndroidRuntime(457): FATAL EXCEPTION: AsyncTask #2
08-19 09:22:15.521: ERROR/AndroidRuntime(457): java.lang.RuntimeException: An error occured while executing doInBackground()
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.lang.Thread.run(Thread.java:1019)
08-19 09:22:15.521: ERROR/AndroidRuntime(457): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at android.os.Handler.&lt;init&gt;(Handler.java:121)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at android.app.Activity.&lt;init&gt;(Activity.java:680)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at com.xont.controller.syn.DownlaodTableActivity.&lt;init&gt;(DownlaodTableActivity.java:62)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at com.xont.controller.admin.DailyDownloadActivity$DailyDownldAsyncTask.doInBackground(DailyDownloadActivity.java:83)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at com.xont.controller.admin.DailyDownloadActivity$DailyDownldAsyncTask.doInBackground(DailyDownloadActivity.java:1)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-19 09:22:15.521: ERROR/AndroidRuntime(457):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
</code></pre>

<p>Please help me ....</p>

<p>Thanks in advance</p>
