get arraylist values passed to asynctask at doinbackground
android, android-asynctask, arrays, java
Solution
you can get value by this code
class test extends AsyncTask<ArrayList<String>, Void, Void>
{
@Override
protected Void doInBackground(ArrayList<String>... creds) {
// TODO Auto-generated method stub
String str1 = creds[0].get(0);
String str2 = creds[0].get(1);
return null;
}
}
Problem
I have an Asynctask setup I pass an Arraystring like this ``` ArrayList<String> creds = new ArrayList<String>(); creds.add(string1); creds.add(string2); new myasynctask().execute(creds); ``` asynctask method class myasynctask extends AsyncTask<ArrayList, Integer , String> DOinbackground ``` protected String doInBackground(ArrayList<String>... creds) { String lol1= creds[0].toString(); String lol2= creds[1].toString(); ........rest of the code } ``` I get an Array index out of bond exception how do I pass tow values into the doinbackground method and get both of them at once.