Reputation: 859
Lets say I have a class like below;
class X {
private List<String> listing;
class XAsync extends AsyncTask... {
<normal async task class>
doInBackground {
listing = <populating from a web service>
}
}
public redirectList() {
while(listing.size == 0) {
continue;
}
redirect(listing);
}
}
How to make sure that listing parameter sending within redirect method is populated successfully from async task? Making sure that listing is populated with while clause is a best practice or not?
Thanks
Upvotes: 0
Views: 42
Reputation: 20147
You should return the value to be put in listing
from doInBackground
, and then use it in onPostExecute
. That is, your redirect(listing);
call should be in onPostExecute
, and then you won't have any need for that while loop.
Upvotes: 1