所以我有代码向服务器发送请求并获得响应。响应取决于我发送到服务器的参数集。但由于某种原因,我得到了相同的结果。这是一个代码:我调用sendDashboardRequest
了两组不同的参数:
LinkedHashMap<String, Object> serverParameters = new LinkedHashMap<String, Object>();
serverParameters.put("user_id", result.get("user_id"));
serverParameters.put("limit", Integer.valueOf(1000).toString());
serverParameters.put("type", Integer.valueOf(1).toString());
sendDashboardRequest(serverParameters);
serverParameters.put("type", Integer.valueOf(2).toString());
sendDashboardRequest(serverParameters);//Executes only this AsyncTask twice!
sendDashboardRequest
这是启动新 AsyncTasks的方法的代码:
public void sendDashboardRequest(LinkedHashMap<String, Object> params) {
new AsyncTask<LinkedHashMap<String, Object>, Void, LinkedHashMap<String, Object>>()
{
NetworkOp lowLevelOps = new NetworkOp();
@Override
protected LinkedHashMap<String, Object> doInBackground (LinkedHashMap<String, Object>... params)
{
return lowLevelOps.executeCommand(DASHBOARD_COMMAND, params[0]);
}
protected void onPostExecute(LinkedHashMap<String, Object> result)
{
//And here I gave the same result!But parameters which I send to the server are different!
}
}.execute(params);
}
最有趣的是,当我创建两个具有相同主体的不同方法并为不同的参数集调用每个方法时,一切正常,两个不同的 AsyncTasks 启动。