Android: Cannot specify return type <String> for AsyncTask: doInBackground
I have the following code based on asynctask code. I am trying to return a List variable using return LoadFeed () and the return type doInBackground is a string. If I change the return type doInBackground from String to List, then I get an error
"The return type is incompatible with AsyncTask<String,Void,String>.doInBackground(String[])"
How to fix this error? Please, help
Thank,
private class DispData extends AsyncTask<String, Void, String> {
private final ProgressDialog dialog = new ProgressDialog(MessageList.this);
// can use UI thread here
protected void onPreExecute() {
dialog.setMessage("Fetching scores...");
dialog.show();
}
// automatically done on worker thread (separate from UI thread)
protected String doInBackground(final String... args) {
return loadFeed();
}
// can use UI thread here
protected void onPostExecute(final List<String> result) {
if (dialog.isShowing()) {
dialog.dismiss();
}
adapter =
new ArrayAdapter<String>(MessageList.this,R.layout.row,result);
MessageList.this.setListAdapter(adapter);
}
}
+3
2 answers