I have the following class:
public class getURLData extends AsyncTask{
@Override
protected String doInBackground(String... params) {
String line;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(params[0]);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
line = "Can't connect to server";
} catch (MalformedURLException e) {
line = "Can't connect to server";
} catch (IOException e) {
line = "Can't connect to server";
}
return line;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
}
And I am trying to call it like this:
String output = null;
output = new getURLData().execute("http://www.domain.com/call.php?locationSearched=" + locationSearched);
But the output variable isn't getting data, instead I am getting an error:
Type mismatch: cannot convert from AsyncTask to String