我正在开发安卓应用程序。我需要从 onpostexecute 方法中获取值。即我需要用onpostexecute 方法的返回值做一些任务。我怎样才能做到这一点?请在这方面帮助我。
我的代码:
boolean val= false;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LongOperation1 op = new LongOperation1();
op.execute("");
//I want the value here again
}
private class LongOperation1 extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
loadFeed2();
return "Executed";
}
@Override
protected void onPostExecute(String result) {
dialog1.dismiss();
try {
dialog.dismiss();
//mystuff
val = true;
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@Override
protected void onPreExecute() {
dialog1 = ProgressDialog.show(Taketest.this, "Please wait...",
"Retrieving data ...", true);
}
@Override
protected void onProgressUpdate(Void... values) {
}
}