Reputation: 12857
First AsyncTask is with
protected String doInBackground(String... params) {
while(true)
//...getting chat messages from IRC server
}
After clicking on button Open Account I starting another AsyncTask with json
protected String doInBackground(String... args) {
JSONObject json = jsonParser.makeHttpRequest("https://"),"GET", params);
//..........
}
Second AsyncTask can not be done because first is running and don't let to second get connection.
How to set on pause the first AsyncTask and resume after done of the second? on pause, because I can't stop first.
Upvotes: 0
Views: 327
Reputation: 1551
Try to start the second AsyncTask using another executor...
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Upvotes: 2
Reputation: 3745
According to the documentation:
When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution.
If you truly want parallel execution, you can invoke executeOnExecutor(java.util.concurrent.Executor, Object[]) with THREAD_POOL_EXECUTOR.
http://developer.android.com/reference/android/os/AsyncTask.html
Upvotes: 2