i want to get the value returns by asynctask after it's been completed. this is my code :
class asyncGet extends AsyncTask<Void, String, String> {
Boolean goterror = false;
@Override
protected String doInBackground(Void... params) {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response;
try {
request.setHeader("Cache-Control", "no-cache");
request.setHeader("Cache-Control", "no-store");
response = client.execute(request);
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache");
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
str.append(line);
}
in.close();
return str.toString();
} catch (Exception e) {
goterror = true;
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (pDialog != null && pDialog.isShowing())
pDialog.dismiss();
if (result != null && goterror == false) {
}
}
The async is in another class , I want to show the result when it's done .
How can I return the result from the async ?
thanks