Answer the question
In order to leave comments, you need to log in
Where is the best place to interact with the view?
Where is it better to interact with the view: in the onPostExecute method in the AsyncTask descendant class, or with the get() method to receive the result of the doInBackground method in the activity and interact with the view already there?
Answer the question
In order to leave comments, you need to log in
It is better to try to use less AsyncTask, But:
1) AsyncTask - to perform asynchronous operations.
2) .get() makes it synchronous (doInBackground() is not executed on MainThread, but MainThread is waiting for execution to finish).
So the answer is, of course, in onPostExecute! Because otherwise the whole point of using AsyncTask is lost.
In the method onPostExecute()
. The method get()
blocks the work of the thread that called this method (in your case it will be the ui thread if you want to interact with View
) until doInBackground()
it finishes its work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question