我创建了一个异步任务来调用我的服务器从DB获取数据.
我需要处理从http服务器调用返回的结果.
从我的活动我在许多地方调用异步任务.所以我不能使用成员变量来访问结果.有什么办法吗?
public Result CallServer(String params)
{
try
{
new MainAynscTask().execute(params);
}
catch(Exception ex)
{
ex.printStackTrace();
}
return aResultM;//Need to get back the result
}
private class MainAynscTask extends AsyncTask {
@Override
protected Result doInBackground(String... ParamsP) {
//calling server codes
return aResultL;
}
@Override
protected void onPostExecute(Result result) {
super.onPostExecute(result);
//how i will pass this result where i called this task?
}