【发布时间】:2014-02-16 07:40:54
【问题描述】:
我的 AsyncTask 类在 for 循环中不起作用。以下是我的代码,请查看。
for (int i = 0; i < size; i++) {
String id = careplan_disease_Parser.DiseaseID.get(i);
String method = "GetCarePlan_Comment?CurrentValue=0&OptionId=" + id + "&DiseaseID=" + id + "&OrgId=" + orgId + "";
String link = "GetCarePlan_Comment_dislink";
task = new AsyncTask123();
task.execute(link, method);
method=null;
link=null;
task=null;
}
任务只执行一次。所以我无法在循环中第二次从网络服务中获得价值。 请帮助我如何使它工作。
谢谢
【问题讨论】:
-
尝试将
for loop移动到doInBackround()内部AsyncTask123() -
当我在后台执行循环时。它给了我错误 java.lang.RuntimeException: Can't create handler inside the thread that has not called Looper.prepare()
-
并确保请不要在
doInBackround()中调用AsyncTask123(),仅从那里调用Http请求 -
是的,我没有再次调用 asyncTask123()。但出现同样的错误,请帮助我。
标签: android web-services xml-parsing android-asynctask