java - 在另一个异步任务中执行异步任务
问题描述
我正在尝试在 OnPostExecute 中调用另一个异步任务。第二个任务似乎根本没有运行。我无法从日志中打印任何内容。
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
try {
JSONObject json = new JSONObject(result);
JSONArray lignes = json.getJSONArray("lignes");
populatelist(lignes);
}
catch (JSONException e) {
}
}
}
populatelist 函数填充一个数组。在这个函数中,我尝试调用第二个异步任务来获取基于这个列表的值。
protected void populatelist(JSONArray lignes){
try {
for(int i=0;i<lignes.length(); i++) {
JSONObject jsonas = lignes.getJSONObject(i);
String fdesignation = jsonas.getString("designation");
String fqtecde = jsonas.getString("qtecde");
String fcode_produit = jsonas.getString("code");
InfoStock(fcode_produit);
items.add(new PickingListProduitItem(fdesignation,"",fqtecde, ""));
}
}
catch(Exception e){
}
}
InfoStock() 是用于从 Web 服务返回附加信息的函数。
protected void InfoStock(String code_produit){
String stockURL = "http://" + mSharedPreferences.getString(Constants.SERVER_IP,"")+"//rest/v2/produit/info/code/"+ code_produit + "?stock=true";
try {
if (mDownloader != null && mDownloader.getStatus() == AsyncTask.Status.RUNNING) {
mDownloader.cancel(true);
mPDialog.dismiss();
}
mPDialog = new ProgressDialog(getApplicationContext());
mDownloader = new XMLDownloader(getApplicationContext(),mPDialog);
byte[][] downloadResults = mDownloader.execute(stockURL).get();
// Read stock info.
String s = new String(downloadResults[0], StandardCharsets.UTF_8);
JSONObject resp = new JSONObject(s);
PrixStockJSONParser psj = new PrixStockJSONParser(resp);
mRepInfoStock = psj.getRepInfoStock();
mRepInfoPrix = psj.getRepInfoPrix();
} catch (Exception ex) {
}
}
我正在尝试在OnPostExecute
方法中创建的数组 <> 中设置一个值。但是没有,并且根本没有error message
填充数组。即使我尝试从该函数打印日志,它也不会执行任何操作。InfoStock
欢迎任何建议。
解决方案
推荐阅读
- node.js - 无法使用 node.js 访问 BigCommerce WebDAV
- c# - 如何为特定行着色
- angular - 使用 Angular 和 firebase 编辑/更新响应式表单
- php - 如何将图形从 python 程序显示到网站?
- angular - 如何在angular6中通过target.querySelector获取输入值
- laravel - Laravel - 突出显示已分配给用户的角色
- c# - 使用 OutputFormatter 时未设置 ASP.NET CORE MVC Content-Length Header
- excel - 将多个工作表拆分为工作簿时,有没有办法保留工作表?IE。像首页/摘要表
- android - 从 Android 库模块中的资产中读取 json 文件
- html - 是否可以在按钮的 img 旁边添加文本?