The compiler error is “The method execute(ArrayList<String>...) in the type AsyncTask<ArrayList<String>,Void,ArrayList<String>> is not applicable for the arguments (String)“
Why wouldn’t it accept the new parameter? can anyone see what i am doing wrong?
ArrayList<String> passing = new ArrayList<String>();
passing.add(logicalUrl);
passing.add("filename.pdf");
new myTask().execute(logicalUrl);
return true;
}
public class myTask extends AsyncTask<ArrayList<String>, Void, ArrayList<String>> {
ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(ModuleContents.this);
dialog.setTitle("Downloading...");
dialog.setMessage("Please wait...");
dialog.setIndeterminate(true);
dialog.show();
}
protected ArrayList<String> doInBackground(ArrayList<String>... passing) {
ArrayList<String> passed = passing[0];
String physicalUrl = parsePhysicalUrl(passed.get(0));
String filename = passed.get(1);
try {
globals.saveFile(physicalUrl, filename);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return passed;
}
You have
new myTask().execute(logicalUrl)logicalUrl isStringbut you specified in generic that should beArrayList<String>So change it to
or add as argument of your class
ArrayListthat you created.and now it should work. It seems you only overlooked it :]