I use async tasks to hit the web server and update the controls using the result. This has flaws, namely, what makes the asynchronization methods specific to the controls and stops me again with the return string.
How to return a returned string from an asynchronous call to onPostExecute? What should I call it? I can't seem to get my code to do this. There should be no problems with stream processing, since I have a dialog that freezes the user interface until the task is completed.
My typical asyncTask code is as follows
class GetDataFromServer extends AsyncTask<String, String, String>
{
* */
private ProgressDialog qDialog;
private Context context;
private String dialogString;
private ArrayList<String[]> newLoginResult;
String url_newGame ="http://xxxxxx.php";
public myAsyncMethos(String dialogMessage, Context con)
{
this.qDialog = new ProgressDialog(con);
this.dialogString = dialogMessage;
this.context = con;
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
qDialog = new ProgressDialog(this.context);
qDialog.setMessage(this.dialogString);
qDialog.setIndeterminate(false);
qDialog.setCancelable(false);
qDialog.show();
}
@Override
protected JSONObject doInBackground(String... args)
{
return jsonNewUser;
}
public void onPostExecute(JSONObject jsonString)
{
qDialog.dismiss();
}
}
source
share