Issue
I am trying to set a variable in an activity to the result of my AsyncTask. I have read that I cannot return a variable and that I would have to set up the variable in my activity and then change it in the onPostExecute
method.
My problem is that after the AsyncTask finishes I need to use that variable. I am having trouble with this because all the solutions I have tried so far cause the UI to freeze up and then go non-responding.
What I have tried so far:
while (!task.isCancelled()) {
// Wait...
}
And
while (variable == null) {
// Wait ...
}
Is what I am doing the best way to pass a variable from the AsyncTask to my Activity? If it is then how can I wait for the task to finish in the activity without locking up the UI?
Solution
Just put your code which you want to execute after the Variable is changed in a function and call this function from onPostExecute.
Answered By - Adnan Amjad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.