0

Currently in my application, in one fragment (or adapter), I call more than one AsyncTask in order to gather required data for that fragment.

I am following this tutorial link to make sure that I do not block the UI while data is loading from server.

But since I call more than one AsyncTask in my fragments / adapters, I realized that this method will not work for me and I started to doubt if I am using AsyncTask correctly.

So, is it okay to call more than one AsyncTask in one fragment/adapter?

WheelPot
  • 307
  • 1
  • 3
  • 15
  • asynctask can be executed only once. if you want to start it several times you have to get new instance new MyAsinkTask().execute() see this http://stackoverflow.com/questions/6373826/execute-asynctask-several-times – Konstantin Volkov Feb 29 '16 at 21:08

2 Answers2

0

You can invoke as many AsyncTasks as you want within reasonable limits. Just be aware that AsyncTask behaves differently on different versions of Android, as documented in AsyncTask under the "Order of execution" heading.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
0

Yes, you could, try with:

AsyncTask.THREAD_POOL_EXECUTOR();
Stanojkovic
  • 1,612
  • 1
  • 17
  • 24