Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在另一个异步任务内执行异步任务_Java_Android_Android Asynctask - Fatal编程技术网

Java 在另一个异步任务内执行异步任务

Java 在另一个异步任务内执行异步任务,java,android,android-asynctask,Java,Android,Android Asynctask,我试图在OnPostExecute中调用另一个异步任务。第二个任务似乎根本没有运行。我无法在日志中打印任何内容 @Override protected void onPostExecute(String result) { super.onPostExecute(result); try { JSONObject json = new JSONObject(result); JSONArray lignes = j

我试图在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){

    }
}
我试图在
OnPostExecute
方法中创建的数组中设置一个值。但是,没有
错误消息
,并且根本不填充数组。即使我尝试从
InfoStock
函数打印日志,它也不会执行任何操作


欢迎任何建议。

我正在尝试调用OnPostExecute中的另一个异步任务。这个调用到底在哪里,我在你的代码中看不到?除了@Sam所说的,这看起来是rxjavas的一个完美用例。你不应该有空的try/catch语句,记录你的异常错误,这将有助于debugging@Sam.InfoStock(fcode_produit)是使用新的XMLDownloader执行异步任务的函数。@Rafsanjani,代码运行时不会抛出异常
 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) {

    }
}