Search code examples
androidandroid-asynctask

Pass values to AsyncTask


I'm developing an android app and I'm kinda stuck on this issue, and that I can not pass a variable AsyncTask correctly. Is that moving from the main series of the form execute (value), but i dont know how taking that value inside the AsyncTask (doInBackground).


Solution

  • String... urls this is your method parameter.

    Excute runs doInBackground method and yu can pass them like below

    new Conexion().Execute("tip","tip1"...)

    then you can use it in doInBackground

    ArrayList<NameValuePair> categoria = new ArrayList<NameValuePair>();
        categoria.add(new BasicNameValuePair("tipo", urls[0]));
        categoria.add(new BasicNameValuePair("tipo1", urls[1]));
        .
        .