1

i want to execute two AsyncTask in parallely. Basically I wanted to do when I click on a button you run the two AsyncTask but at the same time are not so ... On the first part click the first to second the second in the order! I would understand if it is possible go start them with the click of a button!

I write below the code that I utilzizato to let her go:

public void onClick(View arg0){
    switch(arg0.getId()) {
        case R.id.btn_down:
            if(isOnline() == true){
                //
                // new ShowDialogAsyncTask().execute();
                new AsynTask2().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,null);
                new ShowDialogAsyncTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,null);



            }
            else{
                Toast.makeText(this,"Connettiti a Internet",Toast.LENGTH_SHORT).show();
            }

            break;
    }
}
4

2 回答 2

0

第一个异步任务的 onPostExecute 可以启动第二个

 protected void onPostExecute(Long result) {
     new AsynTask2().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,null);
 }
于 2013-06-25T09:07:38.310 回答
0

是关于如何并行运行多个 AsyncTask() 的非常有用的讨论。

此外,还有一个例子可以证明这一点。

希望这可以帮助 .... :)

于 2013-06-25T09:18:09.543 回答