Several simultaneous AsyncTasks from different Activities - how to catch proper response?
<p>I have several <code>Activities</code> and each of them has its own <code>AsyncTask</code> which sends requests to a server and catches its responses. These days if <code>AsyncTask</code> is in execution I have a <code>ProgressDialog</code> which blocks User from navigation to another <code>Activities</code>. I want to get rid of the <code>ProgressDialog</code> and substitute it with <code>ProgressBar</code> view so user can switch between <code>Activities</code>. My concern is about the following: what if <code>AsyncTaskFirst</code> started in <code>ActivityFirst</code> and user navigates to <code>ActivitySecond</code> where <code>AsyncTaskSecond</code> is starting also, couldn't it happen the <code>response</code> from the first request will take ground in <code>ActivitySecond</code> so I'll miss it in <code>ActivityFirst</code>? If it is impossible, that's fine. If it is - how to handle such a case? Thank you very much in advance.</p>
